211k views
4 votes
Write a pseudo code that performs the following: Ask a user to enter a number. If the number is between 10 and 20, write the word Hello. If the number is between 20 and 30, write the word Nice. If the number is between 30 and 40, write the word Hi. If it is any other number, write that it is not a correct option.

1 Answer

6 votes

Final answer:

The pseudo code provided checks a user-entered number against specific ranges and prints messages like "Hello", "Nice", or "Hi" based on the range it falls into, or else it indicates an incorrect option if the number does not fit any range.

Step-by-step explanation:

The subject of your question is related to basic computer programming logic, specifically the use of conditional statements in pseudo code. Pseudo code is not written in a specific programming language, but instead is a general way of describing an algorithm that can then be implemented in any number of programming languages. Here's an example of pseudo code based on your requirements:

START
Prompt the user to enter a number
Read the user's number
IF the number is >= 10 AND <= 20 THEN
Write "Hello"
ELSE IF the number is > 20 AND <= 30 THEN
Write "Nice"
ELSE IF the number is > 30 AND <= 40 THEN
Write "Hi"
ELSE
Write "Not a correct option"
END

This pseudo code will ask the user for a number and will then check which range it belongs to. It will display an appropriate message based on the range, or inform the user that the entered number is not a correct option if it does not fall into any of the specified ranges.

User Joe Alfano
by
7.9k points