- Use The Function You Defined In Part 1 To Write A Program For Guees The Number Game In This Game The User Is To Guess 1 (60.31 KiB) Viewed 25 times
Use the function you defined in Part 1 to write a program for "Guees the Number" game. In this game the user is to guess
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Use the function you defined in Part 1 to write a program for "Guees the Number" game. In this game the user is to guess
Use the function you defined in Part 1 to write a program for "Guees the Number" game. In this game the user is to guess a random number in the range [1, 100] generated by the computer. Here are the steps that the program takes: 1. The program calls the function declared in Part 1 to generate a random integer in the range [1, 100]. 2. The program then asks the user to guess the number generated in the previous step. 3. If the user enters the correct number, the program alerts "You won!" and terminates. 4. If the number entered by the user is not in the range [1, 100], the program alerts an error message and goes to Step 2. 5. If the number entered by the user is less than the random number generated in Step 1, the program displays "Enter a larger value" and goes to Step 2. 6. If the number entered by the user is greater than the random number generated in Step 1, the program displays "Enter a smaller value" and goes to Step 2. The program continues until the user guesses the number correctly