Factorial Program in C++

Beneath I have shared the factorial program in C++.

Factorial is the result of a number and every one of the numbers underneath it. For instance factorial of 4 is equivalent to 24.

In the event that you have any issue with respect to beneath factorial program in C++, at that point you can unreservedly ask it by remarking underneath.

#include<iostream>
 
using namespace std;
 
int main()
{     
	unsigned long i,fac,n;
	cout<<"Enter number: ";
	cin>>n;
 
	for(i=1,fac=1;i<=n;++i)
	{
		fac=i*fac;
	}
 
	cout<<"Factorial of "<<n<<" is: "<<fac;
	return 0;
}

Output

Enter number: 5

Factorial of 5 is: 120

Leave a Comment

error: Alert: Content is protected!!