Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 3 of 3.
Any three of these four statements, each with its reason:
Statement: Count ← INT(100 / Number) can fail if Number is 0, which is a divide by zero [1]
Statement: Index ← Data[Number] can fail if Number is outside the array range 1 to 100 (or the lower bound) [1]
Statement: ReturnValue ← TO_UPPER(RIGHT(Label, Count)) can fail if Count is negative or larger than the length of Label [1]
Another accepted statement: RETURN RetVal fails because RetVal does not exist (the variable is called ReturnValue). Only three marks at most.
Write:
Construct: a loop (pre-condition or post-condition, such as WHILE or REPEAT) [1]
Explanation: the condition to end the loop is never met, so it repeats forever [1]
Use one IF statement. Index MOD 2 is 0 or 1, so ELSE covers 1:
IF Index MOD 2 = 0 THEN
ReturnValue ← TO_UPPER(RIGHT(Label, Count))
ELSE
ReturnValue ← "****"
ENDIFIF ... THEN ... ELSE ... ENDIF structure [1]
Correct test and both assignments in the right branches [1]
▶ Whole paper
Video solution of the whole paper · by Papersdock. 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.