Question: Your Tasks In this lab, you will make additions to a C + + program provided. The program is a guessing game. A random number
Your Tasks
In this lab, you will make additions to a C program provided. The program is a guessing game. A random number between and is generated in the program. The user enters a number between and trying to guess the correct number. If the user guesses correctly, the program congratulates the user and then the loop that controls guessing numbers exits; otherwise, the program asks the user if they want to guess again. If the user enters Y they can guess again. If the user enters N the loop exits. You can see that the Y or N is the sentinel value that controls the loop. Note that the entire program has been written for you. You need to add code that validates correct input, which is Y or N when the user is asked if they want to guess a number, and a number in the range of through when the user is asked to guess a number.
Instructions
Comments have been included in the code to help you identify where these loops should be written.
Task : Write loops that validate input at all places in the code where the user is asked to provide input.
Task : The program can be executed several times to ensuring the random number changes.
An example of the program is shown below:
Do you want to guess a number? Enter Y or N: Y
Im thinking of a number...
Try to guess by entering a number between and :
That's not correct. Do you want to guess again? Enter Y or N: Y
Im thinking of a number...
Try to guess by entering a number between and :
That's not correct. Do you want to guess again? Enter Y or N: N
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
