#include <iostream>
usingnamespace std;
int factorial(int x){
if (x==0)
{
return(1);
}
else
{
int p;
x*= factorial(x-1);
return(x);
}
}
int main()
{
cout << factorial(7);
}
But if i change the return Value in the if statement to return(2), i get 10080.
or (return value in if statement multiplied by original answer which is supposed to be produced.
but what if i want the if statement to return 2,3 or any other value when equal to zero, and avoid multiplying the 'if' return value with the else return value;
because the result will be affected by the return values of the if statement