Answer to Question #273997 in C++ for Ga-Eul

Question #273997

LOOPING STATEMENTS AND FUNCTIONS


Create a flowchart to guide you in the process

Create a function that will accept the value of i and return the value of 

Possible values of i is any positive value from 2 to 10

is computed based on the value of i; see the following table for the sample Input / Output

!!Please see these 3 examples on how the screen will work when the program runs!!

1.)

i : 3

Process: 1*2*3

n: 6


2.)

i: 5

Process: 1*2*3*4*5

n: 120


3.)

i: 7

Process: 1*2*3*4*5*6*7

n: 5040


Screen/Layout

(Home Screen)

Input i:3

Process: 1*2*3

Output: 6


Try Another [Y/N]: Y



Input i: 5

Process: 1*2*3*4*5

Output: 120


Try Another [Y/N]: Y


1
Expert's answer
2021-12-01T18:38:49-0500
#include<iostream>
#include<string>
using namespace std;
int main(){
	int i;
	cin>>i;
	int factorial = 1;
	string results = " ";
	cout<<"Process: ";
	for(int x=1; x<=i; x++){
		factorial *= x;
		results +=  to_string(x) + "*";
	}
	cout<<results<<endl;
	cout<<"n: "<<factorial<<endl;
}

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
APPROVED BY CLIENTS