Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is what the instructions say: Extend the function of Exercise 4 so that it

ID: 3619570 • Letter: T

Question

This is what the instructions say:

Extend the function of Exercise 4 so that it also outputs a running total of the numbers as they are entered. For example, the I/O dialog might be the following:

Enter positive number, 0 to end: 10 Total: 10 Enter positive number, 0 to end: 20 Total: 30 Enter positive number, 0 to end: 30 Total: 60 Enter positive number, 0 to end: 0 The function then outputs 30 20 10 The Previous exercise said: Write a recursive function that asks the user to enter a positive integer number each time it is called, until zero or a negative number is input. The function then outputs the numbers entered in reverse order. For example, the I/O dialog might be the following: Enter positive number, 0 to end: 10 Enter positive number, 0 to end: 20 Enter positive number, 0 to end: 30 Enter positive number, 0 to end: 0 The function then outputs 30 20 10 The answer I gave was: void PrintInput(int); int main() {       int n = 1;       PrintInput(n);       system("pause");       return 0; } //********************************************* void PrintInput(int x) {    cout << "Enter positive number, 0 to end: ";    cin >> x;    if(x > 0)    {       PrintInput(x);       cout << x << endl;    }    else          return; } This is what the instructions say:

Extend the function of Exercise 4 so that it also outputs a running total of the numbers as they are entered. For example, the I/O dialog might be the following:

Enter positive number, 0 to end: 10 Total: 10 Enter positive number, 0 to end: 20 Total: 30 Enter positive number, 0 to end: 30 Total: 60 Enter positive number, 0 to end: 0 The function then outputs 30 20 10 The Previous exercise said: Write a recursive function that asks the user to enter a positive integer number each time it is called, until zero or a negative number is input. The function then outputs the numbers entered in reverse order. For example, the I/O dialog might be the following: Enter positive number, 0 to end: 10 Enter positive number, 0 to end: 20 Enter positive number, 0 to end: 30 Enter positive number, 0 to end: 0 The function then outputs 30 20 10 The answer I gave was: void PrintInput(int); int main() {       int n = 1;       PrintInput(n);       system("pause");       return 0; } //********************************************* void PrintInput(int x) {    cout << "Enter positive number, 0 to end: ";    cin >> x;    if(x > 0)    {       PrintInput(x);       cout << x << endl;    }    else          return; } The Previous exercise said: Write a recursive function that asks the user to enter a positive integer number each time it is called, until zero or a negative number is input. The function then outputs the numbers entered in reverse order. For example, the I/O dialog might be the following: Enter positive number, 0 to end: 10 Enter positive number, 0 to end: 20 Enter positive number, 0 to end: 30 Enter positive number, 0 to end: 0 The function then outputs 30 20 10 The answer I gave was: void PrintInput(int); int main() {       int n = 1;       PrintInput(n);       system("pause");       return 0; } //********************************************* void PrintInput(int x) {    cout << "Enter positive number, 0 to end: ";    cin >> x;    if(x > 0)    {       PrintInput(x);       cout << x << endl;    }    else          return; } The answer I gave was: void PrintInput(int); int main() {       int n = 1;       PrintInput(n);       system("pause");       return 0; } //********************************************* void PrintInput(int x) {    cout << "Enter positive number, 0 to end: ";    cin >> x;    if(x > 0)    {       PrintInput(x);       cout << x << endl;    }    else          return; }

Explanation / Answer

please rate - thanks
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote