Worked solution from the Algorithm Design and Problem-solving Paper 2 Problem-solving and Programming booklet, Part 2 of 2.
Fill the shapes like this:
First decision: is Num1 > Num2 AND Num1 > Num3? [1]
Yes: set Ans to Num1 [1]
No leads to a second decision: is Num2 > Num3? Yes: set Ans to Num2; No: set Ans to Num3 [1]
Process box after the three branches join: set Average to (Num1 + Num2 + Num3) / 3 (do not use DIV) [1]
Output parallelogram: OUTPUT a message with Ans and Average [1]
The outer loop repeats until Flag is TRUE. Inside it, Port goes 1 to 3 (the flowchart stops when Port = 4).
Flag ← GetStat()
WHILE Flag <> TRUE
FOR Port ← 1 TO 3
CALL Reset(Port)
NEXT Port
Flag ← GetStat()
ENDWHILEOuter conditional loop that tests Flag [1]
Flag assigned from GetStat() inside the loop (and before it) [1]
Inner loop that counts Port [1]
Inner loop runs for 3 iterations (Port 1, 2, 3) [1]
CALL Reset(Port) inside the loop [1]
A REPEAT ... UNTIL Flag = TRUE with an IF around the FOR loop also scores.
▶ Starts at Q2 (13:11)
Starts at Q2 (13:11) · by Pseudocode Pro. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.