Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3.
Work out when each CALL runs. Sub1 runs when A, B and C are all TRUE. Sub2 runs when A and B are TRUE and C is FALSE. Sub3 runs when A is FALSE and C is FALSE (B can be either, because both paths call Sub3). Sub4 runs when A is FALSE and C is TRUE. Write:
IF A AND B AND C THEN
CALL Sub1()
ENDIF
IF A AND B AND NOT C THEN
CALL Sub2()
ENDIF
IF NOT A AND NOT C THEN
CALL Sub3()
ENDIF
IF NOT A AND C THEN
CALL Sub4()
ENDIFFirst IF...THEN...ENDIF correct: A AND B AND C calls Sub1() [1]
Second correct: (A AND B) AND NOT C calls Sub2() [1]
Third correct: (NOT A) AND (NOT C) calls Sub3(), with B left out because it does not matter [1]
Fourth correct: (NOT A) AND C calls Sub4(), with B left out [1]
▶ Whole paper
Video solution of the whole paper · by Audere Prep. 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.