#include<iostream> //Calling the Header File.
int main() //Declaring the main function
{
usingnamespace std; //Tells the compiler that we'll be using all the standard C++ library functions
int a,factorial=1;
cout<<"Enter the number: "; //Ask for the number.
cin>>a;
for(int i=1;i<=a;i++)
{
factorial=factorial*i;
}
cout<<"The factorial of the given number is: "<<factorial<<endl;
return 0;
}
// to calculate the factorial of a number (n!)
#include<iostream>
usingnamespace std;
int main()
{
int num,factorial=1;
// user factorial input
cout<<"Enter a number to find its factorial: ";
cin>>num;
// a = 1, number less then 1 equals number, increase the number by 1
for(int a=1;a<=num;a++)
{
// factorial = 1 *
factorial=factorial*a;
}
//Factorial number
cout<<"\n\nFactorial number is ="<<factorial<<endl;
// Pause for user
system("pause");
return 0;
}