Cambridge AS Level Computer Science 9618 · 11.2 Constructs

Q41 · 9618/23/M/J/22 Q1

Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3.

Q419618/23/M/J/22original Q1Structured · 8 marks
Question 1 from 9618/23/M/J/22

Worked solution

(a)

Tick what each example uses:

Pseudocode exampleSelectionIterationAssignment
FOR Index ← 1 TO 3 ... NEXT Index✓✓
OTHERWISE : OUTPUT "ERROR 1202"✓
REPEAT UNTIL Index = 27✓
INPUT MyName✓
IF Mark > 74 THEN Grade ← 'A' ENDIF✓✓

FOR loop row: Iteration and Assignment [1]

OTHERWISE row: Selection [1]

REPEAT UNTIL row: Iteration [1]

INPUT row: Assignment [1]

IF row: Selection and Assignment [1]

(b)(i)

Work out each expression:

ExpressionEvaluation
AAA AND (Count > 99)FALSE
AAA AND (NOT BBB)TRUE
(Count <= 99) AND (AAA OR BBB)TRUE
(BBB AND Count > 50) OR NOT AAAFALSE

Any two rows correct [1]

All four rows correct [1]

(b)(ii)

Any one of these:

Use a Boolean as a flag to stop a loop when a value has been found [1]

Or: when a variable can only be one of two values, such as Yes or No, or a light being on or off.

KEY IDEASpot selection, iteration and assignment in code, and evaluate Boolean expressions bracket by bracket.
TOTAL 8 marks

Official mark scheme

Mark scheme for 9618/23/M/J/22 question 1
VIDEO
▶ Whole paper

Video solution of the whole paper · by Digify ID. 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.