Cambridge O Level Computer Science 2210 · 8.1 Programming concepts

Q28 · 2210/21/M/J/24 Q2

Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3.

Q282210/21/M/J/24original Q2Structured · 9 marks
Question 2 from 2210/21/M/J/24

Worked solution

(a)

Match each description to its concept:

DescriptionProgramming concept
a subroutine that may not return a valueprocedure
a value that is declared and used within a specific procedurelocal variable
a value that a procedure expects you to supply when it is calledparameter
a subroutine that will always return a valuefunction

a subroutine that may not return a value → procedure [1]

declared and used within a specific procedure → local variable [1]

a value a procedure expects when called → parameter [1]

a subroutine that will always return a value → function [1]

global variable is not used.

(b)

Use the keyword CALL, then the procedure name with the two values in brackets:

CALL Average(25, 50)

Keyword CALL [1]

Procedure name with the correct parameters, Average(25, 50) [1]

(c)

Write any three points:

Procedures and functions divide the program into smaller manageable parts, so it is easier to read, understand and debug [1]

They can be re-used in the program or in other programs, and run from a single line [1]

They reduce repeated code, so there is less to change when the program is updated [1]

Also accepted: meaningful names act as documentation (abstraction).

KEY IDEAA procedure may not return a value, a function always does; parameters carry values in, local variables stay inside one subroutine.
TOTAL 9 marks

Official mark scheme

Mark scheme for 2210/21/M/J/24 question 2
VIDEO
▶ Whole paper

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