How to Find Factorial of any Number in C++
To find factorial of a number we need two variables and a for loop which is give blew.
#include<iostream>
#include<iostream.h>
int main()
{
int b;
int a=1;
cout<<"enter number to finds its factorial"<<endl;
cin>>b;
for(int c=b;c>1;c--)
{
a=a*b;
}
cout<<a<<endl;
system("pause");
return 0;
}
To find Factorial of given number in C++
#include<iostream>
using namespace std;
int main()
{
int b=4;
int a=1;
for(int c=b;c>1;c--)
{
a=a*b;
}
cout<<a<<endl;
system("pause");
return 0;
};