In C++ program you can write a program to calculate the factorial of an integer. Let's look at the code to calculate the factorial of an integer.
using namespace std ;
#include <iostream>
using namespace std ;
int main ()
{
int i, num, fact=1 ;
cout <<"\n Enter integer" ;
cin>> num;
i = num ;
while (num)
{
fact *=num ;
--num ;
}
cout<< "The factorial of " << i ;
cout<<"is" << fact <<"\n" ;
return 0 ;
}
The output of the C++ Code