Answer to Question #298825 in C++ for Chubby

Question #298825

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).


1
Expert's answer
2022-02-17T02:15:58-0500


#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");
} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog