C++ Program to find factorial of a number without classes
Program
#include<iostream>
using namespace std;
int main() {
int fact = 1, num;
cout << "Enter the number to find factorial:" << endl;
cin >> num;
for (int i = 1; i <= num; i++)
fact = fact * i;
cout << "Factorial of " << num << " is " << fact << endl;
return 0;
}
Output
Enter the number to find factorial:
6
Factorial of 6 is 720