Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics

Q1 · 9618/21/M/J/21 Q1

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

Q19618/21/M/J/21original Q1Structured · 12 marks
Question 1 from 9618/21/M/J/21

Worked solution

(a)

Pick a meaningful name and the data type that matches each example value:

Example valueVariable nameData type
"Wong"MemberNameSTRING
FALSEFamilyMemberBOOLEAN
19/02/1983StartDateDATE
1345PointsINTEGER

Name and type correct for the name row (STRING) [1]

Name and type correct for the FALSE row (BOOLEAN) [1]

Name and type correct for the date row (DATE) [1]

Name and type correct for the points row (INTEGER) [1]

Any sensible, meaningful variable names score.

(b)

Check each statement for a wrong use of an operator or function:

StatementError
Result ← 2 & 4& joins strings. For numbers use an arithmetic operator, or make 2 and 4 into strings
SubString ← MID("pseudocode", 4, 1)NO ERROR
IF x = 3 OR 4 THEN4 is not a Boolean value, so the condition is wrong. It should be x = 3 OR x = 4
Result ← Status AND INT(x/2)INT(x/2) gives a number, not a Boolean value, so AND cannot be used
Message ← "Done" + LENGTH(MyString)You cannot add a string to a number: "Done" is not a number

Row 1 error described [1]

Row 2: write NO ERROR [1]

Row 3 error described [1]

Row 4 error described [1]

Row 5 error described [1]

(c)

Write: Structure = record.

Write: a record can hold different data types [1]

Write: stored under one identifier (one record per student) [1]

Structure named as a record [1]

Alternative: two 1D arrays, one STRING and one INTEGER, where the same index links a name to its score. This scores the same three marks.

KEY IDEAA record holds items of different data types under one name, and each operator or function must be used on the right data type.
TOTAL 12 marks

Official mark scheme

Mark scheme for 9618/21/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.