|
From: softnasolutions-ltd.fsbusiness.co.uk <so...@so...> - 2000-12-06 20:26:42
|
Hi friends, I have just started learning C++ (i'm using a material from Cprogramming.com). I've tried to write a program to recursively calculate the factorial of a number but it doesn't work. Can someone please tell me what i've done wrong, Here is the code: #include <iostream.h> #include <stdlib.h> int factorial_cal(int results) { if (results>0) results=1*results; factorial_cal(results-1); return results; } int main() { int number; int results; cout<< "Enter a number for me to caculate its Factorial"<<endl; cin>>number; results=number; factorial_cal(results); cout<< " The factorial of "<<number<< " is "<<results<<endl; system("PAUSE"); return 0; } |