Cambridge AS Level Computer Science 9618 · 11.3 Structured Programming

Q86 · 9618/23/M/J/24 Q1

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

Q869618/23/M/J/24original Q1Structured · 9 marks
Question 1 from 9618/23/M/J/24

Worked solution

(a)(i)

Write any two of these benefits:

The code can be called whenever it is needed [1]

A later change to the algorithm is made once only, so the program is easier to maintain [1]

Less code, with no duplication (or the algorithm is designed, coded and tested once). Only two of these points can score.

(a)(ii)

Say how the repeated code is turned into a module:

Create a module (function, procedure or subroutine) from the algorithm code [1]

Replace the old code in every place with a call to the module [1]

Pass the data in as parameters (or use global variables) and return the result (or assign it to a global variable or a BYREF parameter). Create local variables if needed. Any one of these points earns the last mark [1]

(b)

Choose the built-in function or operator from the insert that gives each value:

Pseudocode expressionEvaluates to
MID("Random", 2, 3)"and"
5 + DAY(10/11/2023)15
IS_NUM("45000")TRUE
(20 MOD 3) + 13

MID correct [1]

DAY correct [1]

IS_NUM correct [1]

MOD correct [1]

KEY IDEAPut repeated code in one module and call it, passing data in and returning the result.
TOTAL 9 marks

Official mark scheme

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

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