C++ Program to Find Factorial of a Number
Here you will get the source code of C++ Program to Find Factorial of a Number in C++ programming. To find the factorial of a number, use a loop to multiply the number by every number below it until you reach 1.
For Example:-
Factorial of 5, will be 5 * 4 * 3 * 2 * 1 = 120.
C++ Program to Find Factorial of a Number
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | //C++ Program to Find Factorial of a Number #include<iostream> using namespace std; int main() { int num, fact=1; cout<<"Enter a Numbers: "; cin>>num; while(num>=1) { fact=fact*num; num--; } cout<<"\nFactorial = "<<fact; return 0; } |
Output
Check out our other C++ programming Examples