#include <iostream.h>
#include <conio.h>
int factorial(int);
int factorial(int x)
{
if(x==1)
return 1;
else
return (x * factorial(x-1));
}
void main()
{
int n,fact;
cout << "Enter a number to find its factorial : ";
cin >> n;
fact = factorial(n);
cout << "\n\nFactorial of " << n << " is " << fact;
getch();
}
Wednesday, September 15, 2010
Factorial of a number using C++
C++ program to find the factorial of a given number
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment