CPP Program For Factorial

#include<iostream.h>
#include<conio.h>
 
 void main()
{
clrscr();
long a,b,c=1;
cout << "enter any number" << endl;
cin >>a;
for(int i=1;i<=a;i++)
{
c=c*i;
}
cout << c << endl;
getch();
}

Output:
enter any number
5
factorial=120

 

 

Leave a Reply