C++/c++ Recursion !
Expert: Prince M. Premnath - 8/11/2007
Questionwrite a programe in c++ to find the factorial to any no
through iterative procedure or recursive procedure
AnswerHi Dear Qaiser !
Thanks for your question !
Here im presenting you the simple version of C++ program to calculate factorial of an integer using recursive procedure !
/*
C++ Program to find factorial of a given number using recursion
*/
#include<iostream.h>
int fact(int n)
{
if( n <= 0 )
return 1;
else
return n* fact( n - 1);
}
void main()
{
int no;
cout<<"Enter a number :";
cin>>no;
cout<<"Fact "<<fact(no);
}
Thanks and Regards !
Prince M. Premnath
princeatapi@yahoo.co.in