Answer to Question #274126 in C++ for Hope

Question #274126

Please put Try Another[Y/N]:

here in this code.


#include <iostream>

using namespace std;

int main(){

int i;

cout<<"Input i: ";

cin>>i;

cout<<"Process = ";

int fact = 1;

int n = 1;

for(int x=i; x>=1; x--){

fact *= x;

cout<<n <<"*";

n++;

}

  cout<<"\nOutput: "<<fact<<endl;

}



1
Expert's answer
2021-12-01T10:36:08-0500
#include<iostream>
using namespace std;

int main()
{
	int i;
	char choice;
	do
	{
		cout<<"Input i: ";
		cin>>i;
		cout<<"Process = ";
		int fact = 1;
		int n = 1;
		for(int x=i;x>=1;x--)
		{
			fact*=x;
			cout<<n<<"*";
			n++;
		}
		cout<<"\nOutput: "<<fact;
		do
		{
			cout<<"\nTry Another[Y/N]:";
	    	cin>>choice;
		}while(choice!='N'&&choice!='Y'&&choice!='n'&&choice!='y');
	}while(choice!='N'&&choice!='n');
}

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