Algorithmic Rigour 0 / 45
Architect Rank Syntax Error

Topic 2.1.4: Writing Algorithms

Pseudocode, Logic Errors, and Flowcharts.

1 [5 Marks]
switch destination: case "UK": cost = 5.00 case "EU": cost = 12.50 case "US": cost = 20.00 default: cost = 35.00 endswitch
(a) Output for "EU"?
(b) Output for "Asia"?
(c) Rewrite using IF / ELSE IF.
Structure:
if destination == "UK" then ...
elseif ...
else ...
✅ Mark Scheme

(a) 12.50

(b) 35.00 (Default case)

if destination == "UK" then cost = 5.00
elseif destination == "EU" then cost = 12.50
elseif destination == "US" then cost = 20.00
else cost = 35.00
endif
Score:
2 & 3 [5 Marks]
Q2. Flowchart Trace: Input Price = 50. Condition `Price > 50`.
What is the Discount? What is Output?

Q3. Code:
for i = 2 to 10
  print(i)
  i = i + 1
Why does this NOT print 2, 4, 6...?
Q2: Is 50 > 50? (True or False)
Q3: The loop automatically adds 1 to i. You are adding another 1.
✅ Mark Scheme

Q2: 50 > 50 is False. Discount = 0. Output = 0.

Q3: The loop increments `i` automatically. Adding `i = i + 1` means it increases by 2 each time, skipping numbers.

Score:
4, 5, 6 [9 Marks]
Q4. if age > 17 (Logic error). Correct it.
Q5. Infinite loop: while password != "Secret" but no input inside loop. Fix it.
Q6. if colour == "Red" OR "Blue". Why is this wrong?
Q6 Hint: The computer reads "Blue" as a separate "True" statement. It doesn't know you mean colour == "Blue".
✅ Mark Scheme

Q4: if age >= 17 (or > 16).

Q5: Add password = input(...) inside the loop.

Q6: "Blue" evaluates to True on its own. Correct: if colour == "Red" OR colour == "Blue".

Score:
7 [5 Marks]
Write algorithm for Vending Machine Change.
- Input Price, Input Money.
- Calc Change.
- If Change < 0 output "Not enough" . Else output Change.
✅ Mark Scheme
price = input("Price")
money = input("Inserted")
change = money - price
if change < 0 then
  print("Not enough money")
else
  print(change)
endif
Score:
8 [6 Marks]
Calculate average of 5 scores using a Loop.
Hint: You need a total variable starting at 0.
✅ Mark Scheme
total = 0
for i = 1 to 5
  score = input("Enter score")
  total = total + score
next i
average = total / 5
print(average)
Score:
9 [6 Marks]
Flowchart Construction for Temperature check.
Describe the shapes/flow or draw it on paper.
- Temp < 0 (Freezing)
- 0 to 100 (Liquid)
- > 100 (Gas)
✅ Mark Scheme
  • Start/Stop: Rounded Rectangles.
  • Input Temp: Parallelogram.
  • Decision 1: Diamond (Temp < 0?) -> Yes: Output "Freezing".
  • Decision 2: Diamond (Temp > 100?) -> Yes: Output "Gas".
  • No path (Else): Output "Liquid".
Score:
10 [7 Marks]
Search array students (size 30) for "Sarah".
Output "Found" or "Not Found".
Use a Loop.
✅ Mark Scheme
found = False
for i = 0 to 29
  if students[i] == "Sarah" then
    print("Found")
    found = True
    break (or exit loop)
  endif
next i

if found == False then
  print("Not Found")
endif
Score: