Question: Write a program named Lab 1 1 B . Randomly generate an integer between 0 and 1 0 0 and ask the user to enter

Write a program named Lab11B.
Randomly generate an integer between 0 and 100 and ask the user to enter a guess.
Compute the absolute value of the difference between the user guess and the secret number.
Print the absolute value of the difference and
if it is <=10, print Warm.
otherwise, print Cold.
Keep asking for a guess and printing Warm or Cold until the user guesses the right number.
Use a flag-controlled while loop to accomplish this task.
To generate a random number:
Add #include & #include with your other include statements
Declare an int variable named randomNum to hold the random number
Add this code after your variable declarations:
srand(time(0));
randomNum = rand()%101;

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 Programming Questions!