C++ program to find the factorial of a given number
kw.cpp
#include<iostream>usingnamespacestd;intmain(){longi,n,fact=1;cout<<"———————————————————————————————————————————";cout<<"\nProgram to find the factorial of a given number ";cout<<"\n———————————————————————————————————————————";cout<<"\nEnter the number ";cin>>n;if(n>20||n<0){cout<<"\nOOP's can't find "<<n<<"!";}else{for(i=1;i<=n;i++){fact=fact*i;}cout<<"\nFactorial of "<<n<<" = "<<fact;}cout<<"\n———————————————————————————————————————————\n";return0;}
Output
kodingwindow@kw:~$ g++ kw.cpp kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to find the factorial of a given number
———————————————————————————————————————————
Enter the number 25
OOP's can't find 25!
———————————————————————————————————————————
kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to find the factorial of a given number
———————————————————————————————————————————
Enter the number 15
Factorial of 15 = 1307674368000
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?