Make a C++ program using while loop to find the factorial of a positive integer entered by user. (Factorial of n = 1*2*3....*n).
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
int n,i=1;
long int factorial=1;
cout<<"Enter the Number: ";
cin>>n;
while(i<=n){
factorial*=i;
i++;
};
cout<<"The factorial of "<<n<<" is "<<factorial<<"\n\n";
system("pause");
}
Comments
Leave a comment