Source Code:
#include<iostream>
using namespace std;
int main()
{
int i,factorial=1,n;
cout<<"Enter a number: ";
cin>>n;
for(i=1;i<=n;i++)
{
factorial=factorial*i;
}
cout<<"The factorial of the number is: ";
cout<<factorial;
return 0;
}
Program Output:
0 Comments