I am trying to write a recursive function, but get an error in the line : n + sum(n-1); My compiler is German, so a poor translation of the error message would be: "void value not ignored as supposed to". Thanks for help!
void sum (int n)
{
if(n==0)
{
cout << n << endl;
}
else if(n>0)
{
n + sum(n-1);
cout << n << endl;
}
}
int main()
{
sum(3);
return 0;
}
voidfunctions and cannot get return values from them.