Cambridge AS Level Computer Science 9618 · 12.2 Program Design

Q29 · 9618/23/M/J/25 Q6

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

Q299618/23/M/J/25original Q6Structured · 9 marks
Question 6 from 9618/23/M/J/25

Worked solution

(a)

Write one difference (either scores):

A function returns a (single) value but a procedure does not [1]

Or: a procedure can pass parameters by reference (BYREF). Only one point is needed.

(b)

Read each module on the chart. An arrow with an open circle is data passed in. An arrow with a filled circle is a flag. The data types are given in the question.

Sub_Part1A takes only R (INTEGER) and returns nothing, so it is a procedure:

PROCEDURE Sub_Part1A(R : INTEGER)

PROCEDURE with its name and parameter R : INTEGER [1]

Sub_Part2A takes T (REAL) and returns a flag (BOOLEAN), so it is a function:

FUNCTION Sub_Part2A(T : REAL) RETURNS BOOLEAN

FUNCTION with parameter T : REAL [1]

RETURNS BOOLEAN [1]

Sub_Part3A takes V (INTEGER), W (BOOLEAN) and U (STRING) which goes in and comes back out, so U is passed by reference:

PROCEDURE Sub_Part3A(V : INTEGER, W : BOOLEAN, BYREF U : STRING)

PROCEDURE with parameters V : INTEGER and W : BOOLEAN [1]

BYREF U : STRING [1]

(c)

Write what each symbol means, using the module names:

Diamond: selection, so Main calls either Sub_A or Sub_B (decided when the program runs) [1]

Curved arrow: repetition (iteration), so Sub_A repeatedly calls Sub_Part1A, then Sub_Part2A, then Sub_Part3A [1]

Both explanations use the correct module names [1]

KEY IDEAIn a structure chart a diamond means selection, a curved arrow means repetition, and arrows with circles show the parameters and return values that make up each module header.
TOTAL 9 marks

Official mark scheme

Mark scheme for 9618/23/M/J/25 question 6
VIDEO
▶ Whole paper

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