What is an algorithm?
A step-by-step set of instructions to solve a problem.
Give a correct pseudocode input statement.
INPUT age
What arithmetic operator is used in:
total = cost * number ?
Multiplication operator (*)
What two conditions are checked in:
INPUT
number IF number >= 1 AND number <= 10 THEN
OUTPUT “Valid”
ELSE
OUTPUT “Invalid”
ENDIF
number ≥ 1 and number ≤ 10.
Write pseudocode to compare two colors.
IF color1 == color2 THEN
OUTPUT "The colors match"
ELSE
OUTPUT "The colors do not match"
ENDIF
Why are algorithms important?
They ensure tasks can be carried out accurately and computers follow clear steps.
Name two rules of pseudocode.
Use simple English-like statements;
use ALL CAPS for keywords.
Write a correct output using the variable score.
OUTPUT "Your total score is:", score
If the input is 0 for that algorithm, what is the output?
Invalid
Write pseudocode to check which number is larger.
IF num1 > num2 THEN OUTPUT num1
ELSEIF num2 > num1 THEN OUTPUT num2
ELSE OUTPUT "The numbers are the same"
What is a logic error?
A mistake where the algorithm runs but produces the wrong result.
What keyword must end decision blocks in pseudocode?
ENDIF
In the expression:
result = value1 + value2 * 2
What is calculated first?
value2 * 2, because multiplication has higher precedence.
Trace this algorithm with inputs (5, 1, 10).
INPUT first INPUT second INPUT third IF first < second AND first < third THEN result ← second * third ELSEIF second < third THEN result ← first * third ELSE result ← first * second ENDIF OUTPUT result
What is the final output?
50
Write pseudocode to determine the largest of three numbers.
The “largest of 3” algorithm from the guide.
Give one example of a logic error.
Using + instead of *
wrong condition
or incorrect output wording.
Rewrite this Python statement in pseudocode:
print("Hello", name)
OUTPUT "Hello", name
What is the logic error in this pseudocode?
INPUT nights
INPUT type
IF type == "elite" THEN
cost ← 100 * nights
ELSE
cost ← 50 + nights
ENDIF
It should be 50 * nights, not 50 + nights.
In the tracing example, why is the second condition true?
Because 1 < 10.
What correction is needed if a pseudocode IF statement is missing THEN?
Add THEN after the condition.
Why is testing algorithms with sample inputs important?
It helps find logic errors
tests different values
checks edge cases
and confirms correct outputs.
What is the correction for this pseudocode error?
Add THEN and proper indentation.
What does the algorithm total = cost * number calculate?
The total cost by multiplying cost × number.
In the algorithm comparing numbers and colors, what is output if both numbers are the same?
"The numbers are the same"
For the 3-number largest algorithm, what is output if c is the largest?
OUTPUT "The largest number is ", c