As the error message clearly states, the function unknown is missing the return type. This is not legal in C++.
Seeing as you're returning 'result', which is an int, unknown() should probably return an int: int unknown(int x)
For the compiler, it's not enough for the function to return an int variable. The return type has to be declared.
How about you try it instead of arguing with someone who knows more than you?
But Sir , I know that you know more than me.you dont have to remind me that.
How can I try it when I dont know what you are saying.
return type is int.
and it is declared.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include<iostream>
usingnamespace std;
unknown(int x)
{
int result; //return type is declared.
int y=2;
if (x>=6)
return 1;
else
result=unknown(x+2)*y;
return result;
}
int main()
{
cout<<unknown(1);
return 0;
}