More Parameter Lists Purpose. The purpose of this lab is to make you feel more comfortable with using parameter lists when calling a function from main, by having you make changes to an existing program's function calls. It also gives you more practice with the "random number generator". Requirements. Rewrite the addition.cpp program from chapter 8, and name it myAddition.cpp. Modify the program by using the C++ random number generator to generate the two input numbers for each question. Limit the randomly-selected input numbers to between 0 and 10, inclusive. To avoid having identical code appearing in main 5 times, because specific numbers no longer appear in the parameter lists of the calls, modify main to use a count-controlled loop that calls the function. NOTE: You need this as the first statement in "main": srand (time (0)); Never put srand(time (0)); in a loop or function (other than main) -- it should be executed only once. Program I/O. Input: 5 whole numbers, each in response to a math problem. Output: 5 correct/incorrect responses to a user input. Examples. Here's what the output should look like, with user input in blue: 6 + 4 = 10 Correct! 6 + 6 = 12 Correct! 3 + 7 = 11 Very good, but a better answer is 10 5 + 9 = 14 Correct! 10+ 3 = 13 Correct!

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.6: The Standard Template Library (stl)
Problem 2E
icon
Related questions
Question

#include <iostream>
using namespace std;

void additionProblem(int topNumber, int bottomNumber)
{
int userAnswer;
cout << "\n\n\n " << topNumber << " + " << bottomNumber << " = ";
cin >> userAnswer;
cin.ignore(1000, 10);

int theAnswer = topNumber + bottomNumber;
if (theAnswer == userAnswer)
cout << " Correct!" << endl;
else
cout << " Very good, but a better answer is " << theAnswer << endl;
} // additionProblem

int main()
{
additionProblem(8, 2);
additionProblem(4, 8);
additionProblem(3, 7);
additionProblem(4, 10);
additionProblem(11, 2);
} // main 

 

The above code needs to be modified according to the image I've attatched.

More Parameter Lists
Purpose. The purpose of this lab is to make you feel more comfortable with using parameter lists
when calling a function from main, by having you make changes to an existing program's function
calls. It also gives you more practice with the "random number generator".
Requirements. Rewrite the addition.cpp program from chapter 8, and name it
myAddition.cpp. Modify the program by using the C++ random number generator to generate the
two input numbers for each question. Limit the randomly-selected input numbers to between 0 and
10, inclusive.
To avoid having identical code appearing in main 5 times, because specific numbers no longer
appear in the parameter lists of the calls, modify main to use a count-controlled loop that calls the
function.
NOTE: You need this as the first statement in "main": srand (time (0)); Never put
srand(time (0)); in a loop or function (other than main) -- it should be executed only once.
Program I/O. Input: 5 whole numbers, each in response to a math problem. Output: 5
correct/incorrect responses to a user input.
Examples. Here's what the output should look like, with user input in blue:
6 + 4 = 10
Correct!
6 + 6 = 12
Correct!
3 + 7 = 11
Very good, but a better answer is 10
5 + 9 = 14
Correct!
10+ 3 = 13
Correct!
Transcribed Image Text:More Parameter Lists Purpose. The purpose of this lab is to make you feel more comfortable with using parameter lists when calling a function from main, by having you make changes to an existing program's function calls. It also gives you more practice with the "random number generator". Requirements. Rewrite the addition.cpp program from chapter 8, and name it myAddition.cpp. Modify the program by using the C++ random number generator to generate the two input numbers for each question. Limit the randomly-selected input numbers to between 0 and 10, inclusive. To avoid having identical code appearing in main 5 times, because specific numbers no longer appear in the parameter lists of the calls, modify main to use a count-controlled loop that calls the function. NOTE: You need this as the first statement in "main": srand (time (0)); Never put srand(time (0)); in a loop or function (other than main) -- it should be executed only once. Program I/O. Input: 5 whole numbers, each in response to a math problem. Output: 5 correct/incorrect responses to a user input. Examples. Here's what the output should look like, with user input in blue: 6 + 4 = 10 Correct! 6 + 6 = 12 Correct! 3 + 7 = 11 Very good, but a better answer is 10 5 + 9 = 14 Correct! 10+ 3 = 13 Correct!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

The program should be according to the requirement. The requirement says, "Modify the program by using the C++ random number generator to generate the
two input numbers for each question." also, there should be a count-controlled loop in the main To avoid having identical code appearing in the main 5 times.

Please refer to the requirements of the program.

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr