HOw to find factorial of a given number in C++ Language?
I am working on a program that asks a user to enter a # between 1 to 50 and finds the factorial of that. It uses recursive function to find it.
Here is what I got so far:
Its not working, can some please help me solve this problem.
using namespace std;
void printResult(int, int);
num = getNum();
ans = fact(num);
cout << endl << endl;
cout << "\nEnter a number:";
cin >> num;
int fact(int num)
if (num == 0)
return num * fact(num - 1);
void printResult(int num, int ans)
cout <<"\nfactorial of" << num << "is : " << ans;
edit: sorry, I have posted this again, because previously I accidentally posted on C section.