Program to find factorial of a number

0
33

In this program, you will find the logic to find factorial of a number:

#include
using namespace std;
int main()
{
int num, i, fact=1;
cout<<"Enter a number (positive integer) : ";
cin>>num;
for(i=1; i<=num; i++)
{
fact=fact*i;
}
cout<<"Factorial of "<<num<<" is "<<fact;
return 0;
}

Output:

output of program to find factorial of a number