Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 3.
Read the algorithm line by line. Lines 01 and 05 share one mark, so they can earn only one mark between them. Any four marks score:
Line 05: IF is wrong. A loop is needed, so write REPEAT [1] (or give the line 01 correction below instead, for the same mark)
Line 07: the city goes in column 1, so write INPUT City[Count, 1] [1]
Line 11: the loop stops too early. Write UNTIL Count > 50 (or UNTIL Count = 51) [1]
Line 12: the output loop only runs once. Write FOR Out ← 1 TO 50 [1]
Line 01: should be DECLARE City : ARRAY[1:50, 1:2] OF STRING (names are text, not BOOLEAN, and a colon is needed after City). This scores in place of line 05, not as well as it.
Write any five of these changes:
Add an input (with a prompt) asking for the country to search for [1]
Store it in a new variable, placed between lines 11 and 12 [1]
Inside the output FOR loop add an IF statement, between lines 12 and 13 [1]
The IF checks if the country in the current array element (City[Out, 2]) matches the country entered [1]
The output in line 13 only happens THEN (when it matches); if it does not match, move on and check the next element [1]
If the country does not match, the program moves on and checks the next element [1]
▶ Whole paper
Video solution of the whole paper · by Paper solver.. 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.