Question: In this exercise, you will modify the guessing game program from Figure 9-11 in Chapter 9. Follow the instructions from starting C++ and viewing the

In this exercise, you will modify the guessing game program from Figure 9-11 in Chapter 9. Follow the instructions from starting C++ and viewing the Introductory15.cpp file, which is contained in either the Cpp8\Chap10\Introductiory15 Project folder or the Cpp8\Chap10 folder. (Depending on your C++ development tool, you may need to open this exercises project/solution file first.) Modify the program so that it uses a void function to determine the random number. The program should ask the user for both the minimum and maximum random numbers that the void function should generate. The function call should pass that information to the void function. test the application appropriately.

Figure 9.11 from Ch9

#include "stdafx.h"

#include

#include

#include

using namespace std;

int main()

{

int randomNumber = 0;

int numberGuess = 0;

//generate a random number from 1 through 10

srand(static_cast(time(0)));

randomNumber = 1 + rand() % (10 - 1 + 1);

//get first guess from user

cout << "Guess a number from 1 through 10: ";

cin >> numberGuess;

while (numberGuess != randomNumber)

{

cout << "Sorry, guess again: ";

cin >> numberGuess;

} //end while

cout << endl << "Yes, the number is "

<< randomNumber << "."

<< endl;

return 0;

} //end of main function

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!