Answer to Question #266954 in C++ for jc given

Question #266954

Create a flowchart to guide you in the process


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


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


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



i Process n


3 1*2*3 6


5 1*2*3*4*5 120


7 1*2*3*4*5*6*7 5040



1
Expert's answer
2021-11-16T13:52:26-0500
#include <iostream>


using namespace std; 


int fact(int num){
	int ans = 1;
	for(int i = 1; i <= num;i++){
		ans *= i;
	}
	return ans;
}


int main(int argc, char *argv[]){
	int a;
	cin >> a;
	if (a >= 2 && a <= 10){
	}else{
		return -1;
		}
	
	cout << fact(a);
}

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