Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics

Q2 · 9618/22/M/J/21 Q1

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

Q29618/22/M/J/21original Q1Structured · 11 marks
Question 1 from 9618/22/M/J/21

Worked solution

(a)(i)

Match each example value to its data type:

VariableData type
NameSTRING
IndexINTEGER
ModifiedBOOLEAN
HolidayDATE

Name: STRING [1]

Index: INTEGER [1]

Modified: BOOLEAN [1]

Holiday: DATE [1]

(a)(ii)

Use Modified = FALSE, Index = 100, Name = "Catherine":

ExpressionEvaluates to
Modified OR Index > 100FALSE
LENGTH("Student: " & Name)18
INT(Index + 2.9)102
MID(Name, 1, 3)"Cat"

FALSE OR (100 > 100) = FALSE OR FALSE = FALSE [1]

"Student: " has 9 characters and "Catherine" has 9, so 18 [1]

100 + 2.9 = 102.9, INT removes the decimal part: 102 [1]

The first 3 characters: "Cat" (keep the quotation marks and the capital C) [1]

(b)

StatementSelectionAssignmentIteration
Index ← Index + 1✓
IF Modified = TRUE THEN✓
ENDWHILE✓

Index ← Index + 1 is assignment [1]

IF ... THEN is selection [1]

ENDWHILE ends a loop, so it is iteration [1]

KEY IDEAChoose the data type from the kind of value stored, and work through expressions one function at a time.
TOTAL 11 marks

Official mark scheme

Mark scheme for 9618/22/M/J/21 question 1
VIDEO
▶ 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.