Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Using Code Emailed Proj1p1cpp Complete Implementation Method Factorial Program Works Prope Q35586878

Using the code you were emailed proj1_P1.cpp you are to completethe implementation of the method Factorial such that the programworks properly. Once complete email back proj1_P1.cpp Output fromyour 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 <iostream>#include <string>using namespace std;// Student should add a function prototype block hereint 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;}

Leave a Reply

Your email address will not be published. Required fields are marked *