Wednesday, July 6, 2011

Program to find the Factorial of the given number


Factorial of a given number is as follows:-


5! = 5*4*3*2*1 = 120


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n=0,i=0,f=1;
cout<<"Enter the number"<<endl;
cin>>n;
for(i=1;i<=n;i++)
{
 f*=i;
}
cout<<f<<endl;
getch();
}

No comments:

Post a Comment