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!
#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!](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5a4a4196-402b-41d8-8cc6-400e379b188a%2F438b8bf7-85aa-41dd-ba60-e17084e12c7a%2Fgb3bizj_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
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.
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)