Computer Science 9618/23 May/June 2025: question paper and mark scheme
Cambridge AS & A Level Computer Science (9618), Paper 2 Fundamental Problem-solving and Programming Skills, May/June 2025. Read both free below, or download them. Done the paper? Get it marked by AI against this mark scheme.
A program is being developed for the management of a sports centre.
(a) The programmer developing the software decides to use modules (procedures or functions) and local variables. They also decide not to use global variables.
(i) State two reasons why the programmer decides to use modules.
1 ……
2 ……
[2]
(ii) State one difference between local and global variables.
…… [1]
(iii) State two benefits of using local variables.
1 ……
2 ……
[2]
(b) The pseudocode design contains a number of expressions.
Complete each pseudocode expression so that it evaluates to the value shown.
Refer to the insert for the list of pseudocode functions and operators.
Expression Evaluates to
'D'
……(68)
2
……(04/02/2025)
FALSE
……TRUE
1.4
……(…… ("Court1.4Upper" ,……,……))
[5]
(c) The table lists some of the variables used in the program.
Complete the table by writing the most appropriate data type for each variable.
Variable Use of variable Data type stores how many members have used the sports
MemberCount centre each day
TotalTakings stores the total amount of money taken each day
stores the state of a booking for an exercise class;
BookingConfirmed a booking is either confirmed or not confirmed to calculate when to send an email with a birthday
MemberDOB message to a member
[4]
Mark scheme
1(a)(i) MP1 When a task/module is repeated / reused / called // performed in 2
several places
MP2 A specific task can be identified /coded as a module / subroutine /
procedure / function.
MP3 Reduces complexity of program / code // Program / code is
simplified
MP4 Module / subroutine / procedure / function already available.
MP5 Testing / debugging / maintenance is easier
Max 2
1(a)(ii) MP1 Local variables are used within a module // are accessible only within 1
the module (in which they are declared)
MP2 Global variables are accessible to all parts of the program /
MP3 Local variables use memory only while the module in is executing //
Global variables use memory for the whole time the program is
running
Max 1
1(a)(iii) MP1 The same variable name can be reused in other parts of the 2
program
MP2 Using local variables makes modules self-contained // cannot
accidentally change the same identifier outside of the module
MP3 Using local variables aids modularisation.
MP4 Memory allocated to local variables can be reused when module not
in use
Max 2
1(b) Mark as follows: 5
Expression Evaluates to Mark
CHR(68) 'D' 1
MONTH(04/02/2025) 2 1
// -2 + DAY(04/02/2025)
// -2023 + YEAR(04/02/2025)
NOT TRUE FALSE 1
// FALSE = TRUE
STR_TO_NUM(MID("Court1.4Upper",6,3)) 1.4 2
Mark Row 4 as follows:
STR_TO_NUM 1 mark
MID("Court1.4Upper",6,3) 1 mark
1(c) 4
Variable Data type
MemberCount INTEGER
TotalTakings REAL
BookingConfirmed BOOLEAN
MemberDOB DATE
Mark as follows:
1 mark per row
A programmer uses a number of Abstract Data Types (ADT) in the programs that she is developing.
(a) A stack using memory locations 400 to 409 is used in one program.
The diagram represents the current state of the stack.
A variable TopOfStack pointer indicates the last value added to the stack.
Stack
Memory
Value location
409
408
407
406
405
404
403 'P' TopOfStack
402 'X'
401 'D'
400 'B'
(i) Complete the answer column in the following table:
Answer the memory location of the value that has been on the stack for
the longest time the number of consecutive push operations that will result in the
TopOfStack variable containing 409
(ii) The diagram shows the current state of the stack.
Stack
Memory
Value location
409
408
407 'A' TopOfStack
406 'C'
405 'F'
404 'K'
403 'B'
402 'S'
401 'R'
400 'D'
The following sequence of operations are performed:
PUSH 'T'
POP
POP
PUSH 'Z'
PUSH 'X'
POP
PUSH 'Y'
Complete the following diagram to show the state of the stack after the operations have been performed.
Stack
Memory
Value location
409
408
407
406
405
404
403
402
401
400
[3]
(b) In a different program, the programmer decides to implement a linked list using an array of records.
(i) The array is represented in the diagram.
A pointer value of –1 indicates the end of the linked list.
Complete the pointer field to produce a linked list that is in alphabetical order.
Index Data Pointer
0 "Neptune"
1 "Jupiter"
2 "Saturn"
3 "Earth"
4 "Mercury"
5 "Uranus"
[3]
(ii) The variable StartPointer contains the index of the first item in the linked list.
State the value of the variable StartPointer
…… [1]
(c) A third program is also being created to manage a queue.
Describe two features of a queue.
Feature one ……
Feature two ……
[2]
Mark scheme
2(a)(i) MP1 400 2
MP2 6
2(a)(ii) 3
Stack
Memory Value
location
409
408 'Y' TopOfStack
407 'Z'
406 ‘C’
405 ‘F’
404 ‘K’
403 ‘B’
3
402 ‘S’
401 ‘R’
400 ‘D’
MP1 TopOfStack pointing to 'Y' and value 'Y' in location 408
MP2 Values 'C' and 'Z' in 406 and 407
MP3 Values 'D' to 'F' unchanged in 400 to 405 and 409 is empty
2(b)(i) 3
Index Data Pointer
0 "Neptune" 2 MP3
1 "Jupiter" 4
2 "Saturn" 5
3 "Earth" 1 MP1
4 "Mercury" 0
5 "Uranus" -1 MP2
MP1 Earth pointer 1
MP2 Uranus pointer -1
MP3 Other four correct pointers
2(b)(ii) 3 1
2(c) MP1 First value added to queue is the first value removed // FIFO // LILO 2
MP2 Two pointers needed to indicate the start and end of the queue
MP3 May behave as a circular queue
MP4 Manipulated using enqueue()/ dequeue() operations // by
description
Max 2
A programmer has been asked to create a module RollDice() to simulate multiple rolls of a dice. This module will be used as part of a program for a game.
The module will:
step 1 – take a positive integer parameter representing the number of times the dice will be rolled
step 2 – simulate one roll of the dice by generating a random integer between 1 and 6 inclusive
step 3 – output the integer generated
step 4 – repeat, as required from step 2
step 5 – calculate the average value of the random integers generated
step 6 – return the average value.
Write pseudocode for the module RollDice()
…… [7]
Mark scheme
3 Example solution: 7
FUNCTION RollDice(NoOfTimes : INTEGER) RETURNS REAL
DECLARE RollValue : INTEGER
DECLARE Average : REAL
DECLARE Count : INTEGER
DECLARE Sum : INTEGER
Sum ← 0
FOR Count ← 1 TO NoOfTimes
RollValue ← INT(RAND(6)) + 1
OUTPUT RollValue
Sum ← Sum + RollValue
NEXT Count
Average ← Sum / NoOfTimes
RETURN Average
ENDFUNCTION
MP1 Declare all variables used and initialise Sum to 0
MP2 Loop for ‘number of times’ parameter
MP3 Use RAND() function with Integer parameter in a loop
MP4 Use INT() function in a loop
MP5 Generate a random integer between 1 and 6 in a loop
MP6 Output each value generated in a loop
MP7 Calculate Sum and if Average used check declared as REAL and
return Average and check function header returns REAL
A programmer is developing a new stock control program for a shop owner to produce sales reports.
(a) A text file Sales.txt stores strings representing the number of items sold.
The file contains 52 lines, each representing the number of items sold in each week of the year.
For example:
File line number File data
1 "350"
2 "502"
3 "434"
49 "492"
50 "872"
51 "772"
52 "201"
The example shows that 502 items were sold in week 2.
The owner requires a module to output all week numbers where the number of items sold is greater than 500.
Describe an algorithm that produces the required module.
Do not include pseudocode statements in your answer.
…… [5]
(b) Once the program has been completed, it is tested using the walkthrough method.
Describe the walkthrough method and explain how it can be used to identify errors.
…… [3]
Mark scheme
4(a) MP1 Open the file (Sales.txt) in read mode and subsequently close 5
MP2 Read a line (from the text file)
MP3 Convert the line read (string) to a number
MP4 If the number is greater than 500 and then output week number
MP5 Increment week number (must have been Initialised …)
MP6 Repeat from step 2 for 52 times // Repeat from step 2 until end of file
Max 5
4(b) MP1 Going through the program a line / statement at a time 3
// doing a dry run
// single-stepping (at run-time with an IDE)
// Peer testing/review is carried out
MP2 Creating a trace table
MP3 Draw up test data // draw up list of inputs with expected output
// boundary, normal, abnormal data is used
MP4 Errors will be indicated when a variable / output gives an
unexpected value
MP5 Faults in the logic of the program can be detected // Errors may be
indicated by an unexpected path through the program
Max 3
A module Parity() takes a string as a parameter. The parameter has the identifier BitString and it represents a binary value.
The module will concatenate a single character to the end of BitString by applying one of the two rules:
• '0' if Bitstring contains an even number of 1s
• '1' if Bitstring contains an odd number of 1s.
The modified value of BitString is then returned.
For example:
Parameter String returned Explanation
"0010010110" "00100101100" there are an even number of 1s in the string passed to Parity() so a '0' is concatenated to the end of BitString
"101010" "1010101" there are an odd number of 1s in the string passed to Parity() so a '1' is concatenated to the end of BitString
Write pseudocode for the module Parity()
Assume the parameter BitString can only contain the characters '0' and '1'
…… [8]
Mark scheme
5 Example solution: 8
FUNCTION Parity(BitString : STRING) RETURNS STRING
DECLARE Index, Count: INTEGER
Count ← 0
FOR Index ← 1 TO LENGTH(BitString)
IF MID(BitString, Index, 1) = '1' THEN
Count ← Count + 1
ENDIF
NEXT Index
IF Count MOD 2 = 1 THEN
BitString ← BitString & '1'
ELSE
BitString ← BitString & '0'
ENDIF
RETURN BitString
ENDFUNCTION
MP1 Function heading and ending and parameter (STRING) and return
type STRING
MP2 Loop for length of BitString
MP3 Extract current character in a loop
MP4 Compare current character to '1' or '0' in a loop
MP5 Increment count and was Initialised earlier in a loop
MP6 Check if even/odd number of 1s
MP7 Append '1' or '0' as appropriate
MP8 Return amended BitString
Study the structure chart:
Main
M
P
Sub_A Sub_B
R V
X
W
T
U
Sub_Part1A Sub_Part2A Sub_Part3A Sub_Part1B Sub_Part2B
Some of the parameter data types are:
• R and V are of type INTEGER
• T is of type REAL
• U is of type STRING
• W is of type BOOLEAN.
Some of the modules in the structure chart are functions, others are procedures.
(a) Explain one difference between functions and procedures.
…… [1]
(b) Write the pseudocode to define the module headers:
Sub_Part1A
Sub_Part2A
Sub_Part3A
[5]
(c) The structure chart uses the two symbols shown.
Complete the table to explain what each symbol means and how the relevant modules in the structure chart are affected.
Symbol Explanation
[3]
Mark scheme
6(a) MP1 A function returns a (single) value and a procedure does not 1
MP2 A procedure can pass parameters by ByRef
Max 1
6(b) Sub_Part1A: 5
PROCEDURE Sub_Part1A(R: INTEGER) 1 Mark
Sub_Part2A:
FUNCTION Sub_Part2A(T : REAL) RETURNS BOOLEAN
2 Marks
Sub_Part3A:
PROCEDURE Sub_Part3A(V: INTEGER, W: BOOLEAN, BYREF U :
STRING)
2 Marks
6(c) 3
Symbol Explanation
The module Main calls either Sub_A or Sub_B (which one
is called is determined at run time)
The module Sub_A will repeatedly call Sub_Part1A followed
by Sub_Part2A then by Sub_Part3A
MP1 Shape1: reference to selection
MP2 Shape2: reference to repetition // iteration
MP3 Descption (×2) including correct use of all module names in both parts
A program is being developed to implement a customer loyalty scheme for a coffee shop.
The programmer has decided that the following data items need to be stored for each customer:
Data item Description
customer ID a unique six-digit string
loyalty points an integer value that depends on how often the customer visits the coffee shop
last visit date the date the customer last visited the coffee shop
The programmer has defined a program module:
Module Description
• called with two parameters:
1. loyalty points of type INTEGER
2. last visit date of type DATE
• change the loyalty points:
increase by four if the last visit date and the current date are in the
UpdateVisit() same month
otherwise increase by one
• change the last visit date to the current date
• the changed values must be available to the code that follows the call to UpdateVisit()
(a) (i) Write pseudocode for module UpdateVisit()
Assume the customer has made at least one previous visit.
[5]
(ii) The programmer decides to amend the UpdateVisit() module so that loyalty points are further increased if the customer visits the coffee shop the same day of the week as their last visit.
Write the pseudocode for this condition.
…… [1]
(b) A text file Loyalty.txt will be used to store the data items for the loyalty scheme.
The text file Loyalty.txt contains only one line of data for each customer.
Each data item is separated by a comma:
<CustomerID>,<LoyaltyPointsString>,<LastVisitDateString>
LastVisitDateString is always eight characters in length in the format: DDMMYYYY.
An example of how a line of data will be stored in the text file Loyalty.txt is:
"100123,132,05032025"
This example shows that the customer with an ID of 100123 had 132 loyalty points following their last visit to the coffee shop on 05/03/2025.
If a customer visits the coffee shop on a Monday, the value of their loyalty points is increased by 10.
The programmer has defined two more program modules:
Module Description
• called with a parameter of type STRING that represents a
FindCustomer() customer ID
• returns the line of data read from the text file Loyalty.txt
(is already written) containing the data items for that customer
MondayCheck() • called with a parameter of type STRING that represents the customer ID of a customer
• calls FindCustomer()
• extracts the loyalty points from the string returned by
FindCustomer()
• increases the loyalty points for the current customer by 10 if the day visited is a Monday
• returns an integer value representing the loyalty points
(i) Write pseudocode for module MondayCheck()
The module FindCustomer() must be used and assume it returns a valid string for the current customer.
…… [8]
(ii) A date is stored in LastVisitDateString in the format:
DDMMYYYY
DD is a 2-digit string
MM is a 2-digit string
YYYY is a 4-digit string.
For example, the date 03/09/2024 is stored as "03092024"
An algorithm is needed to convert the string stored in LastVisitDateString to data
type DATE which is then stored in the variable LastVisitDate.
Complete the pseudocode for this algorithm:
Assume that LastVisitDateString has been declared and contains valid data.
DECLARE DayInt, MonthInt, YearInt : INTEGER
DECLARE LastVisitDate : DATE
[4]
Mark scheme
7(a)(i) Example solution: 5
PROCEDURE UpdateVisit(BYREF LastVisitDate : DATE,__
BYREF LoyaltyPoints : INTEGER)
IF MONTH(TODAY()) = MONTH(LastVisitDate) THEN
LoyaltyPoints ← LoyaltyPoints + 4
ELSE
LoyaltyPoints ← LoyaltyPoints + 1
ENDIF
LastVisitDate ← TODAY()
ENDPROCEDURE
MP1 Procedure heading and ending and two parameters of correct type
MP2 … both passed BYREF
MP3 Use of TODAY() function to obtain current date
MP4 Use MONTH function (×2) and one parameter is the header parameter
and 2nd parameter is TODAY() / assigned variable
MP5 If visit is same month, increase LoyaltyPoints by 4 otherwise
increase by 1
MP6 LastVisitDate set to TODAY() / ‘current date’ variable (assigned
or unassigned)
Max 5
7(a)(ii) DAYINDEX(LastVisitDate) = DAYINDEX(TODAY()) 1
7(b)(i) Example solution: 8
FUNCTION (MondayCheck(CustomerID : STRING) RETURNS
INTEGER
DECLARE LoyaltyPoints : INTEGER
DECLARE LoyaltyPointsString : STRING
DECLARE Line : STRING
Line ← FindCustomer(CustomerID)
LoyaltyPointsString ← MID(Line, 8, LENGTH(Line) –
16))
LoyaltyPoints ← STR_TO_NUM(LoyaltyPointsString)
IF DAYINDEX(TODAY()) = 2 THEN
LoyaltyPoints ← LoyaltyPoints + 10
ENDIF
RETURN LoyaltyPoints
ENDFUNCTION
MP1 Value is returned from FindCustomer(CustomerID) and stored
MP2 Function MID used
MP3 Attempt to extract LoyaltyPoints from the string returned by
FindCustomer()
MP4 Correct extraction of LoyaltyPoints from the string returned by
FindCustomer()
MP5 Conversion of LoyaltyPoints extracted to an integer
MP6 Check - is today’s date a Monday using TODAY()
MP7 … increase LoyaltyPoints by 10
MP8 Return LoyaltyPoints
7(b)(i) Alternative example solution:
Uses a loop to calculate the number of digits in the LoyaltyPoints string
FUNCTION MondayCheck(CustomerID : STRING) RETURNS INTEGER
DECLARE LoyaltyPoints : INTEGER
DECLARE LoyaltyPointsString : STRING
DECLARE Index : INTEGER
DECLARE Line : STRING
Line ← FindCustomer(CustomerID)
Index ← 9
WHILE MID(Line, Index, 1) <> ','
Index ← Index + 1
ENDWHILE
// calculate the number of digits in LoyaltyPoints
string
LoyaltyPointsString ← MID(Line, 8, Index - 8)
LoyaltyPoints ← STR_TO_NUM(LoyaltyPointsString)
IF DAYINDEX(TODAY()) = 2 THEN
LoyaltyPoints ← LoyaltyPoints + 10
ENDIF
RETURN LoyaltyPoints
ENDFUNCTION
7(b)(ii) Example solution: 4
DayInt ← STR_TO_NUM(LEFT(LastVisitDateString, 2))
MonthInt ← STR_TO_NUM(MID(LastVisitDateString, 3, 2))
YearInt ← STR_TO_NUM(RIGHT(LastVisitDateString, 4))
LastVisitDate ← SETDATE(DayInt, MonthInt, YearInt)
Mark as follows:
MP1 Use of one substring function
MP2 DayInt, MonthInt and YearInt all correctly extracted
MP3 Use of STR_TO_NUM x 3
MP4 SETDATE() function used to convert to a date type and assigned to
LastVisitDate
Checked your answers against these? Let AI mark the whole paper, on your own working.
Examiners follow the generic marking principles at the front of the scheme, then each question's points: method (M), accuracy (A) and independent (B) marks, error carried forward where the scheme allows it, and positive marking, so you're credited for what you got right.
Check your answers against it
Done this paper? Upload your script and CIE Buddy's AI marker marks it question by question against this exact scheme, puts the ticks on your own working and says what each lost mark needed.
Where can I find the 9618/23 May/June 2025 mark scheme?+
On this page, free: the mark scheme for AS & A Level Computer Science 9618/23, May/June 2025 (9618_s25_ms_23), and the question paper (9618_s25_qp_23), to read or download, with each question's marking points written out underneath.
How many marks is 9618/23 out of?+
Computer Science 9618/23 for May/June 2025 is out of 75 marks, with 2 hours to answer it.
Can I get my 9618/23 answers marked?+
Yes. Upload your answers to 9618/23/M/J/25 as a PDF or photos, and CIE Buddy marks every question against this paper's official mark scheme, using Cambridge's marking rules. You get your score, each lost mark explained on your own script, and the topics to revise. It's a guide, not an official Cambridge grade.