C++ DEVELOPER SITE
PYTHONPHP7JAVA
 

find Factorial of a Number C++ Tutorial


Following is the program to find factorial of a given number. .

#include<iostream.h>
#include<conio.h>
int main()
{
int i, n1, factorial=1;
clrscr() ;
cout<<"Enter the number to find it's factorial : " ;
cin>>n1 ;
for(a=1;a<=n1;a++){
factorial*=a;
}
if(n1==0)
{
cout<<"\nThe factorial is : 1";
}
else
cout<<"\nThe factorial is : "<<factorial;
getch() ;
return 0;
}

Output

Enter a positive integer: 12
Factorial of 12 = 479001600