Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using the code you were emailed proj1_P1.cpp you are to complete the implementation of the method Factorial such that the program works properly. Once complete
Using the code you were emailed proj1_P1.cpp you are to complete the implementation of the method Factorial such that the program works properly. Once complete email back proj1_P1.cpp Output from your completed program should look like this:
Enter an integer number
3
The factorial of 3 is 6
Do you want to continue y/n
y
Enter an integer number
6
The factorial of 6 is 720
Do you want to continue y/n
y
Enter an integer number
10
The factorial of 10 is 3628800
Do you want to continue y/n
N
Here is the main code to complete:
#include#include using namespace std; // Student should add a function prototype block here int Factorial(int x); int main() { int x; int result; bool looping = true; while (looping) { cout << "Enter an integer number" << endl; cin >> x; result = Factorial(x); cout << "The factorial of " << x << " is " << result << endl; string answer; cout << "Do you want to continue y / n" << endl; cin >> answer; if ((answer.compare("n") == 0) || (answer.compare("N") == 0)) { looping = false; } } return 0; } ///////////////////////////////////////////////////////////////////////////////////////// // // Student needs to supply correct implementation // //////////////////////////////////////////////////////////////////////////////////////////// int Factorial(int x) { int result = 1; // student to add code to compute general factorial of x return result; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started