Question: Write a program that generates a random number (in the range 1 through 10) and asks the user to guess what the number is. If
Write a program that generates a random number (in the range 1 through 10) and asks the user to guess what the number is. If the users guess is higher than the random number, the program should display Too high, try again. If the users guess is lower than the random number, the program should display Too low, try again. The program should use a loop that repeats until the user correctly guesses the random number.
Keep a count of number of guesses the user makes. When the user correctly guesses the random number, the program should display the number of guesses.
Sample output :
Guess a number between 1 and 10: 3
Too low, try again: 5
Too high, try again: 4
You got in 3 attempts.
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
