Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!