Question: How can I modify my code so that ,when the input is not a integer, display Invalid input, try again, and when the input is

 How can I modify my code so that ,when the inputis not a integer, display "Invalid input, try again", and when theinput is not in the range of 1~100, display "Guess out of

How can I modify my code so that ,when the input is not a integer, display "Invalid input, try again", and when the input is not in the range of 1~100, display "Guess out of bounds, try again"

. A function that prompts the player for a guess. This function should keep prompting the player until a valid integer, within the allowed bounds (1 to 100), is entered. The function should then return the guess. If the player supplies an invalid input (e. g. a character, or a floating-point number, scanf O will fail to return 1 (which would mean that it was able to read one integer number). In this case, we need to manually empty the inpuit buffer In order to empty the input buffer, you can use the following code: Bats the bad input until the newline character while (getcharIn') This loop keeps reading characters one by one until a newline character is found

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!