196k views
2 votes
You are planning to write a guessing game program where the user will guess an integer between one and 20. Put the commented steps in the correct order.

The user will keep guessing until correct.

1. First ___ # Compare the user's answer to the correct number.
2. Second __# Give the user a hint as to whether their guess is too high or too low.
3. Third ___# Ask the user for a guess.
4. Fourth ___ # Generate a random numb

User Pushpa
by
8.0k points

1 Answer

1 vote

Final answer:

To create a guessing game program where the user guesses an integer between one and 20, follow these steps: ask the user for a guess, compare the user's answer to the correct number, give the user a hint, and repeat until the guess is correct. The correct answer is A.

Step-by-step explanation:

First, ask the user for a guess.

Second, compare the user's answer to the correct number.

Third, give the user a hint as to whether their guess is too high or too low.

Finally, repeat steps 1-3 until the user's guess is correct.

To program a number guessing game, start by generating a random number, then prompt the user to guess, compare their guess to the correct number, and provide feedback if the guess is too high or low. The guess-feedback loop continues until the correct number is guessed.

To create a guessing game program where the user guesses a number between one and 20, you need to follow these steps:

Generate a random number between 1 and 20 that will serve as the correct answer the user is trying to guess.

Ask the user for a guess. This step involves prompting the user to enter their guessed number.

Compare the user's answer to the correct number to determine if the guess is correct.

Give the user a hint as to whether their guess is too high or too low. This helps guide them towards the correct answer in subsequent guesses.

The user will repeat the process of guessing and receiving feedback until they correctly guess the number. Utilizing a function such as randInt() in a programming language can help implement the random number generation. For example, randInt(1, 20) can be used to generate a random integer between 1 and 20.

User Victoria
by
8.6k points

No related questions found