Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics

Q19 · 9618/21/M/J/24 Q1

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

Q199618/21/M/J/24original Q1Structured · 11 marks
Question 1 from 9618/21/M/J/24

Worked solution

(a)

Match each variable to the kind of value stored:

Assignment statementData type
A ← LEFT(MyName, 1)CHAR (or STRING)
B ← Total * 2INTEGER (or REAL)
C ← INT(ItemCost) / 3REAL
D ← "Odd OR Even"STRING

A: CHAR or STRING [1]

B: INTEGER or REAL [1]

C: REAL (division) [1]

D: STRING [1]

(b)

Use Sorted = False, Tries = 9, ID = "ZGAC001":

ExpressionEvaluates to
Tries < 10 AND NOT SortedTRUE
Tries MOD 41
TO_LOWER(MID(ID, 3, 1))"a"
LENGTH(ID & "xx") >= TriesTRUE

9 < 10 is TRUE and NOT FALSE is TRUE, so TRUE [1]

9 ÷ 4 = 2 remainder 1 [1]

The 3rd character of ID is "A", in lower case "a" [1]

ID & "xx" has 9 characters and 9 >= 9, so TRUE [1]

(c)(i)

Write: the names do not show what each variable is used for (they are not meaningful). [1]

(c)(ii)

Write: the program is harder to understand, debug or maintain. [1]

(c)(iii)

Write any one of: indentation or white space; capital letters for keywords; comments; modular programming; local variables. [1]

KEY IDEAUse meaningful names so the program is easy to read, debug and maintain.
TOTAL 11 marks

Official mark scheme

Mark scheme for 9618/21/M/J/24 question 1
VIDEO
▶ Starts at Q1 (0:23)

Starts at Q1 (0:23) · by Pseudocode Pro. 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.