#include<iostream.h>
#include<conio.h>
void main()
{
int n,i,f=1;
cout<<"Get Number";
cin>>n;
for(i=1;i<=n;i++)
f=f*i;
cout<<"Factorial of n="<<f;
getch();
}
output:
5
Factorial of n=120
#include<conio.h>
void main()
{
int n,i,f=1;
cout<<"Get Number";
cin>>n;
for(i=1;i<=n;i++)
f=f*i;
cout<<"Factorial of n="<<f;
getch();
}
output:
5
Factorial of n=120
why i is used
ReplyDeletethis is very simple and perfect to understand.
ReplyDeleteThank you very much.............!!!!!!!!!!!!!!!!!!!!!