Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics

Q34 · 9618/22/O/N/25 Q1

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

Q349618/22/O/N/25original Q1Structured · 11 marks
Question 1 from 9618/22/O/N/25

Worked solution

(a)

Look at each example for IF/CASE (selection), FOR/WHILE (iteration) and CALL or a function call (subroutine):

Pseudocode exampleSelectionIterationSubroutine
IF Status = FALSE THEN ... FOR ... CALL Reset(Count) ... NEXT Count ... ENDIF✓✓✓
OTHERWISE : Status ← TRUE✓
WHILE AllDone() = TRUE✓✓
30 : NextChar ← 'X'✓

Row 1 correct [1]

Row 2 correct [1]

Row 3 correct [1]

Row 4 correct [1]

(b)

VariableExample data valueData type
Result5.42REAL
MonthLetter"JFMAMJJASOND"STRING
Birthday15/11/2009DATE

REAL [1]

STRING [1]

DATE [1]

(c)

Work each one out:

INT(5.42) = 5, and 5 + 1 = 6, which is not greater than 6, so FALSE.

LENGTH of the string = 12, so NUM_TO_STR gives "12".

Result + "3.2" adds a number to a string, so it is an error.

MONTH(Birthday) = 11, and 11 − 2 = 9. The 9th letter is S.

ExpressionEvaluates to
INT(Result) + 1 > 6FALSE
NUM_TO_STR(LENGTH(MonthLetter))"12"
NUM_TO_STR(Result + "3.2")ERROR
MID(MonthLetter, MONTH(Birthday) − 2, 1)"S"

FALSE [1]

"12" [1]

ERROR [1]

"S" [1]

KEY IDEASelection is IF, CASE; iteration is FOR, WHILE, REPEAT; and mixing a number with a string in + is an error.
TOTAL 11 marks

Official mark scheme

Mark scheme for 9618/22/O/N/25 question 1
VIDEO
▶ Whole paper

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