Answer:
#include <iostream>
using namespace std;
int main()
{
int factorial=1;
int num;
cout<<"Enter any Number: ";
cin>>num;
for(int i=1;i<=num;i++){
factorial=factorial * i;
}
cout<<"The factorial of the number is "<<factorial<<endl;
return 0;
}
Step-by-step explanation:
Create the main function and declare the variable.
then, print the message by using the cout instruction.
store the value enter by user in the variable.
After that, take a for loop from 1 to user value both are included.
and multiply the value with previous value and it happen until the condition in the loop true.
for example:
i=1
fact = 1*1=1
i=2
fact = 1*2=2
i=3
fact= 2*3=6 and so on....
finally print the result.