Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics

Q29 · 9618/23/O/N/24 Q1

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

Q299618/23/O/N/24original Q1Structured · 10 marks
Question 1 from 9618/23/O/N/24

Worked solution

(a)

Decide which constructs each example uses:

Pseudocode exampleSelectionIterationSubroutine
FOR ... IF ... NEXT✓✓
CASE OF Compound(3)✓✓
REPEAT UNTIL AllDone() = TRUE✓✓
WHILE Result[3] <> FALSE✓

FOR loop with IF row correct (selection and iteration) [1]

CASE row correct (selection and subroutine, because Compound(3) is a function call) [1]

REPEAT row correct (iteration and subroutine, because AllDone() is a function call) [1]

WHILE row correct (iteration only) [1]

(b)

Look at the example value:

VariableExample data valueData type
AvailableTRUEBOOLEAN
Received"18/04/2021"STRING
Index100INTEGER

Available is BOOLEAN [1]

Received is STRING (it is in quote marks) [1]

Index is INTEGER [1]

(c)

Use Available = TRUE and Index = 100:

ExpressionEvaluates to
Available AND NOT(Index > 100)TRUE
Index MOD 3010
NUM_TO_STR(Index + "33")ERROR

Index > 100 is FALSE, NOT makes it TRUE, TRUE AND TRUE gives TRUE [1]

100 ÷ 30 = 3 remainder 10, so 10 [1]

Index + "33" adds a number to a string, which is not allowed, so ERROR [1]

KEY IDEACheck the data type of each value before using it in an expression.
TOTAL 10 marks

Official mark scheme

Mark scheme for 9618/23/O/N/24 question 1
VIDEO
▶ Whole paper

Video solution of the whole paper · by Zafar Ali Khan (ZAK). 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.