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

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!