Question: Please, Do not modify Main function. Void guess_num needs to be implemented only. Implement function guess_num that generates a random integer number between 0 and

Please, Do not modify Main function. Void guess_num needs to be implemented only.

Please, Do not modify Main function. Void guess_num needs to be implemented

Implement function guess_num that generates a random integer number between 0 and 100 and lets the user guess the number. The function performs three major steps. First, it generates a random integer number num using the rand function. Second, it prompts the message Enter your guess: and takes a number from the user as input. Third, it checks whether the number entered by the user is identical to num. If so, it displays the message Congrats! Your guess is correct and exits. If the entered number is larger than num, it displays the message Your guess is too large. Try again. and goes back to step 2. If the entered number is smaller than num, it displays the message Your guess is too small. Try again. and goes back to step 2.

You can use the command man rand to find more information on how to use the rand function. A sample execution of the function is as below:

Enter your guess: 27 Your guess is too small. Try again. Enter your guess: 45 Your guess is too large. Try again. Enter your guess: 32 Congrats! Your guess is correct.

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!