Question: In C++: Guessing Game(max of 3 tries): Write a program to simulate the following guessing game using the random_in_range function below:(Basically, the program should generate

In C++:

Guessing Game(max of 3 tries):

Write a program to simulate the following guessing game using the random_in_range function below:(Basically, the program should generate a secret number in the range the use specifies and it guides the user until she gets it right or exhausts 3 attempts.

int random_in_range(int min, int max) //range : [min, max]

{ static bool first = true;

if ( first ) { srand((int)time(NULL)); //seeding for the first time only!

first = false;

}

return min + rand() % (max - min); }

Hint: You will need to include .

The output of your program should be something like this:

Enter min of range 10

Enter max of range 20

Guess a number between 10 and 20

Guess a Number: 17

You went too low

Guess a Number: 18

You got it!

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!