Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Quiz on Chapter 12, Algorithm Design and Problem Solving

Question 1:
Write the pseudocode for the following problem:
Given two inputs, “X” and “Y” as numbers. Write the function that accepts two inputs,
“X” and “Y,” and returns the sum in this range.

Example:
X = 5, Y = 10
Output: 45
Questions 2:
Write the pseudocode for the following problem:
Ask a user to enter a number. If the number is between 0 and 10, write the word “blue”.
If the number is between 10 and 20, write the word “red”. if the number is between 20
and 30, write the word “green”. If it is any other number, write that it is “not a correct
color option.”

Example:
User entered 5
Output: blue
Question 3:
Write the pseudocode for the following problem:
● Read in 5 separate numbers.
● Calculate the average of the five numbers.
● Find the smallest (minimum) and largest (maximum) of the five entered numbers.

Example:
[1, 2, 3, 4, 5]
Output: Average is 15
Smallest is 1
Largest is 5
Question 4:
Write the pseudocode for the following problem:
The function that receives four numbers and writes them all in sorted order.

Example:
[5, 2, 8, 12]
Output: 2, 4, 8, 12

You might also like