Factorial

#include<iostream>
using namespace std;

int main() {
	long int f = 1, no;
	cout << "Program to calculate factorial" << endl;
	cout << "Enter a number:" << endl;
	cin >> no;

	/* Loop the process using "Do While Loop" */
	do {
		f = no * f;
		no = no - 1;
	}
	while(no >= 1);
	cout << "Factorial: " << f << endl;
	return 0;
}


/****** Output ******/

Program to calculate factorial


Enter a number:


5


Factorial: 120

Recommended for you