Past paper – A Level Computer Science (9618)
Cambridge International AS & A Level · 9618
Computer Science · Paper 21
Oct/Nov 2025 · 9618/21/O/N/25
Answer on paper, open each mark scheme and give yourself marks, then open the Summary.
Question text
1
A program is being developed to meet a particular customer requirement.
(a) The program contains these variables:
Variable
Data type
MyChar
CHAR
MyString
STRING
MyInt
INTEGER
MyDOB
DATE
Complete the table by filling in the gaps using functions and/or operators from the insert.
Each expression must be valid.
Expression
MyString
'X' … MyString
MyChar
… ("ABCD", … , … )
MyString
… ( … (MyDOB))
MyInt
… ( … (MyString) / 2)
[4]
(b) Different test methods will be used at different stages of the program development.
Complete the table by identifying the test method that matches the test description.
The first row has been completed for you.
Test description
Test method
carried out as soon as a program module has been coded
alpha
carried out as program modules are being combined
completed by the developers without referring to the code
completed by the customer
[3]
ĬÕĊ®Ġ´íÈõÏĪÅĊßû¸þ×
,
,
(c) During the alpha testing stage, an Integrated Development Environment (IDE) is used to help
locate an error that has been identified. The IDE report window feature is used to examine
the values assigned to variables.
Explain how two other IDE features are used together with the report window feature to help
locate the error.
…
…
…
…
…
… [3]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊßù¸þ×
Question text
2
Data is a global 1D array containing 30 elements of type STRING
An algorithm will output:
•
all non-blank elements (elements that do not contain an empty string)
•
the final total of the number of elements output.
Complete the program flowchart to represent the algorithm:
START
END
[5]
ĬÕĊ®Ġ´íÈõÏĪÅĊÝû¸Ā×
Question text
3
A program is needed to manage individual rentals in a car-hire business.
The data items for each rental will be held in a record structure of type RentalRecord
The programmer has started to define the items that will be needed:
Item
Example value
Comment
RentalID
"AB1234"
a unique alpha-numeric value
CarID
241
a numeric value used as an array index
DisCode
'S'
a letter indicating the type of discount offered
Start
13/06/2025
when the rental starts
Duration
7
the number of days of the rental
Completed
FALSE
TRUE when the car is returned and the rental charge paid
(a) (i)
Write pseudocode to declare the record structure for type RentalRecord
…
…
…
…
…
…
…
… [4]
(ii)
A 1D array Rental containing 500 elements is used to store the data for all rental records.
Write pseudocode to declare the Rental array.
…
… [2]
(b) State three benefits of using an array of records to store the data for all rentals.
1 …
…
2 …
…
3 …
…
[3]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊÝù¸Ā×
[Turn
over
Question text
4
A program contains a global 1D array Number consisting of 20 elements of type REAL
A procedure Store() will input a sequence of up to 20 real values, one value at a time. These
values will be assigned to elements of the array using four steps:
Step 1: store the first value in the sequence in the first element of the array
Step 2: check each subsequent value input. If this value is larger than the previous value input,
then assign the value to the next array element, otherwise go to step 4
Step 3: repeat from step 2 unless the array is full
Step 4: output the count of the number of values stored in the array together with a suitable
message.
(a) Complete the pseudocode for Store()
All variables used in the algorithm must be declared.
PROCEDURE Store()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
ENDPROCEDURE
[6]
ĬÙĊ®Ġ´íÈõÏĪÅĊàùµþ×
,
,
(b) The requirements of the program change:
•
the number of values in the sequence is unknown, but may be higher than 20
•
the values will need to be accessed by another program as data.
The data will be stored in a text file instead of an array.
(i)
Give two benefits of using a text file instead of an array.
1 …
…
Question text
5
A program is being designed in pseudocode.
The program contains the following declaration for the global array MyData:
DECLARE MyData : ARRAY[1:10000] OF STRING
A function FindFirst() is written to search the array for a given string and to return the index of
the first element where that string is found, or to return –1 if the string is not found.
The function is written in pseudocode as shown:
FUNCTION FindFirst(SearchString : STRING) RETURNS INTEGER
DECLARE Index, FoundAt : INTEGER
–1
FoundAt
1 TO 10000
FOR Index
IF MyData[Index] = SearchString THEN // outer conditional clause
IF FoundAt = –1 THEN
// inner conditional clause
Index
FoundAt
ENDIF
ENDIF
NEXT Index
RETURN FoundAt
ENDFUNCTION
(a) (i)
Comment on why the programmer chose –1 as the initial value of FoundAt
…
… [1]
(ii)
Explain the purpose of the outer conditional clause.
…
…
… [1]
(iii)
The inner conditional clause ensures that only the index of the first matching element, if
any, is returned.
Explain how this clause works.
…
…
… [1]
ĬÙĊ®Ġ´íÈõÏĪÅĊÞùµĀ×
,
,
(b) The pseudocode does not use the most appropriate loop construct.
(i)
Explain why this is not the most appropriate loop construct.
…
…
… [1]
(ii)
Suggest and justify a more appropriate loop construct that could be used.
Construct …
Justification …
…
[2]
ĬÛĊ®Ġ´íÈõÏĪÅĊÞûµĀ×
Question text
6
Students are learning about a simple check digit method for data validation. In this method, a
single check digit is appended to the end of an original number to give a new number.
The students are studying a method which:
•
calculates the sum of all the digits in the original number
•
uses integer division to calculate the remainder when the sum is divided by 10
•
uses the remainder as the check digit
•
appends the check digit to the original number, creating the new number.
For example:
original number
4162
sum of all digits
4 + 1 + 6 + 2 = 13
remainder when the sum is divided by 10 using integer division
3
new number
41623
The method described can be used to detect single-digit errors. For example, if the new number
is incorrectly input as 41633, then the check digit does not match and the input will be rejected.
(a) An incorrect attempt was made to enter 41623. The first two digits were entered incorrectly;
the last three digits were entered correctly.
When this number was tested, the check digit was found to be correct and the input was
accepted.
Identify an example of the incorrect attempt to enter 41623 and explain why this number
would not be rejected.
Number …
Explanation …
…
[2]
ĬÙĊ®Ġ´íÈõÏĪÅĊßù·þ×
,
,
(b) A module Generate() will take an integer value representing an original number and return
an integer value representing a new number which includes the check digit.
The original number is always at least three digits in length.
Write pseudocode for the module Generate()
Assume that the parameter is valid.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
7
There are several different ways to express an algorithm during the design of a program.
(a) One part of the program contains an algorithm which is represented by a state-transition
diagram.
The table shows the inputs, outputs and states for the algorithm:
Current state
Input
Output
Next state
S1
A2
X2
S3
S1
A1
X1
S2
S2
A4
X4
S5
S3
A1
S3
S3
A3
X3
S2
S3
A2
X4
S4
S4
A1
X1
S4
S4
A3
S2
S4
A4
X4
S5
Complete the state-transition diagram to represent the information given in the table.
A2 | X2
START
S1
[5]
ĬÙĊ®Ġ´íÈõÏĪÅĊÝù·Ā×
,
,
(b) A structure chart is used to document a different part of the program.
This part of the program contains six modules:
Pseudocode module header
PROCEDURE Setup()
PROCEDURE Restart(H1 : STRING, C1 : INTEGER)
FUNCTION Modify(B1 : BOOLEAN) RETURNS INTEGER
PROCEDURE Final(T1 : INTEGER)
PROCEDURE Update(BYREF R2 : STRING)
FUNCTION Confirm() RETURNS BOOLEAN
Module Setup will repeatedly call three of the modules.
Complete the structure chart to document the information given in the table.
Setup
H1
B1
R2
[5]
ĬÛĊ®Ġ´íÈõÏĪÅĊÝû·Ā×
Question text
8
A program is being developed to manage student book loans from a college library. Students may
borrow up to five books at a time from the library.
The programmer has defined a record type to define each loan.
The record data items are:
Data item
Data type
Comment
StudentID
STRING
the unique ID of the student who has borrowed the book
BookID
STRING
the unique ID of the book being borrowed
OnLoan
BOOLEAN
TRUE if the book has not been returned
The programmer has defined a global array Loan to store 5000 loan records.
There are more elements in the array than books in the library. Unused elements have the
StudentID set to an empty string. These may occur anywhere in the array.
The programmer has defined the first program module:
Module
Description
•
called with a parameter of type STRING representing a
StudentID
•
OKToBorrow()
search the array for loan records for the specified student
•
output a suitable message to say whether the student may, or
may not, borrow another book
ĬÕĊ®Ġ´íÈõÏĪÅĊÞü¶Ă×
,
,
(a) Write efficient pseudocode for the module OKToBorrow()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…