#include<conio.h>
#include<iostream.h>
void main()
clrscr();
int n, i;
unsigned
long f=1;
cout<<"Emter
the Number: ";
cin>>n;
if(n<=0)
cout<<"Please Enter valid number";
else
{
for (i=n; i>=1; i--)
{
f=f*i;
}
cout<<"Factorial of "<<n<<" =
"<<f;
}
getch();
}Output
Enter the Number: 5
Factorial of 5 = 120
No comments:
Post a Comment