Cambridge AS Level Computer Science 9618 · 10.2 Arrays

Q23 · 9618/23/M/J/23 Q1

Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4.

Q239618/23/M/J/23original Q1Structured · 10 marks
Question 1 from 9618/23/M/J/23

Worked solution

(a)

Read the declaration and the loop:

Answer
The dimension of the array2
The name of the variable used as an array indexPCount
The number of elements in the array100

Dimension is 2 because there are two index ranges [1]

Index variable is PCount [1]

2 × 50 = 100 elements [1]

(b)

Error: the second dimension of the array is declared from 1 to 50, but the loop runs from 0 to 49 [1]

Line number: 10 (also accepted: 100, 101 or 102) [1]

(c)

Write: INTEGER [1]

(d)

Decide what each statement does:

Pseudocode statementInputProcessOutput
INPUT MyChoice✓
OUTPUT FirstName & LastName✓✓
WRITEFILE YourFile, TextLine✓
READFILE MyFile, TextLine✓
Result ← SQRT(NextNum)✓

OUTPUT FirstName & LastName: Process and Output ticked (joining the strings is a process) [1]

WRITEFILE: Output ticked [1]

READFILE: Input ticked [1]

Result ← SQRT(NextNum): Process ticked [1]

KEY IDEACount array elements by multiplying the ranges, keep loop limits inside the declared bounds, and know input, process and output.
TOTAL 10 marks

Official mark scheme

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

Starts at Q1 (1:30) · 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.