Computer Science 9618/21 October/November 2025: question paper and mark scheme
Cambridge AS & A Level Computer Science (9618), Paper 2 Fundamental Problem-solving and Programming Skills, October/November 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 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]
* 0000800000003 * DFD
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]
* 0000800000004 * DFD
4
Mark scheme
1(a) 4
Expression
MyString ← 'X' & MyString
MyChar ← MID ("ABCD", 1 / 2 / 3 / 4 , 1)
MyString ← NUM_TO_STR (DAY / MONTH / YEAR / DAYINDEX
(MyDOB))
MyInt ← INT(LENGTH(MyString) / 2)
One mark per row
1(b) 3
Test description Test method
carried out as soon as a program module has been alpha
coded
carried out as program modules are being integration
combined
completed by the developers without referring to black-box
the code
completed by the customer acceptance / beta
One mark per row (2 to 4)
1(c) One mark per point: 3
1 reference to a breakpoint
2 reference to single stepping
3 Correct explanation of both e.g. to stop program execution at specific
point / line / statement / instruction and to execute one line / statement /
instruction at a time to (locate an/the error)
One mark for each bulleted point
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]
* 0000800000005 * DFD
5
Mark scheme
2 Example solution 5
Mark as follows:
1 Initialisation of variables used as array index and count
2 Loop through exactly 30 elements in the array
3 Test for empty string in current array element // Test for non-empty string
4 Increment count if appropriate in a loop
5 Both required outputs under correct conditions with correct outputs
2 Alternative solution
Checking for empty string first
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]
9618/21/O/N/25 [Turn over
* 0000800000006 * DFD
6
Mark scheme
3(a)(i) Pseudocode: 4
TYPE RentalRecord
DECLARE RentalID : STRING
DECLARE CarID : INTEGER
DECLARE DisCode : CHAR
DECLARE Start : DATE
DECLARE Duration : INTEGER
DECLARE Completed : BOOLEAN
ENDTYPE
Mark as follows:
1 One mark for TYPE RentalRecord and ENDTYPE statements
2 One mark for RentalID and CarID declared correctly
3 One mark for DisCode and Start declared correctly
4 One mark for Duration and Completed declared correctly
3(a)(ii) DECLARE Rental : ARRAY[1:500] OF RentalRecord 2
One mark per underlined phrase
3(b) One mark per point: 3
1 Different data types held (for each rental) under a single identifier
2 Allows for iteration through rentals/records //
Can access rentals/records in a loop //
Can (directly) access a specific rental/record using an (array) index
3 Simplifies the code/program / less code needed / reduces code
duplication // Makes code/program easier to understand //
Makes testing / debugging easier //
Program maintenance easier
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]
* 0000800000007 * DFD
7
(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 ……
2 ……
[2]
(ii) State any change that will need to be made before each value is written to the file.
…… [1]
* 0000800000008 * DFD
8
Mark scheme
4(a) Example solution - conditional: 6
PROCEDURE Store()
DECLARE ThisNum, LastNum : REAL
DECLARE Index : INTEGER // index to global array
INPUT ThisNum
LastNum ← ThisNum
Number[1] ← ThisNum
INPUT ThisNum
Index ← 2
WHILE Index < 21 AND ThisNum > LastNum
Number[Index] ← ThisNum
LastNum ← ThisNum
Index ← Index + 1
IF Index < 21 THEN
INPUT ThisNum
ENDIF
ENDWHILE
OUTPUT Index - 1, " values were stored in the array"
ENDPROCEDURE
Alternative loop:
// Loop without using LastNum
WHILE Index < 21 AND ThisNumNum > Number[Index - 1]
Number[Index] ← ThisNum
Index ← Index + 1
IF Index < 21 THEN //skip input if array full
INPUT ThisNum
ENDIF
ENDWHILE
Mark as follows:
1 Declare local variables Index as integer, ThisNum and LastNum as real
2 Input value and assign to first element
3 Attempt at conditional loop including both tests
4 Completely correct conditional loop including both tests
5 Assign input value to current element if greater than previous element
and input next value in a loop
6 Final output giving attempted count of elements stored plus message
after a loop
4(a) Alternative FOR loop example solution:
PROCEDURE Store()
DECLARE ThisNum, LastNum : REAL
DECLARE Index : INTEGER // index to global array
DECLARE Count : INTEGER
INPUT ThisNum
LastNum ← ThisNum
Number[1] ← ThisNum
Count ← 1
INPUT ThisNum
FOR Index ← 2 TO 20
IF ThisNum > LastNum THEN
Number[Index] ← ThisNum
LastNum ← ThisNum
Count ← Count + 1
IF Index < 20 THEN
INPUT ThisNum
ENDIF
ELSE
BREAK
ENDIF
NEXT Index
OUTPUT Count, " values were stored in the array"
ENDPROCEDURE
Alternative loop:
Count ← 1
INPUT ThisNum
FOR Index ← 2 TO 20
IF ThisNum > Number[Index - 1] THEN
Number[Index] ← ThisNum
Count ← Count + 1
IF Index < 20 THEN
INPUT ThisNum
ENDIF
ELSE
BREAK
ENDIF
NEXT Index
Mark as follows:
1 Declare local variables Index as integer, ThisNum and LastNum as real
2 Input value and assign to first element
3 Count-controlled loop
4 Count-controlled loop with BREAK if current value greater than previous
value
5 ... Assign input value to current element following correct comparison
in a loop
6 Final output giving count of elements stored plus message following a
reasonable attempt after loop
4(b)(i) One mark per point: 2
1 The amount of values stored (in a text file) is not fixed / not limited
(other than by secondary storage available) //
The amount values stored is not limited to the size of the array
2 The data is stored permanently / non-volatile //
Data can be restored / reused without re-entering values
4(b)(ii) Each (real) value would have to be converted to a string 1
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
FoundAt –1
FOR Index 1 TO 10000
IF MyData[Index] = SearchString THEN // outer conditional clause
IF FoundAt = –1 THEN // inner conditional clause
FoundAt Index
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]
* 0000800000009 * DFD
9
(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]
* 0000800000010 * DFD
10
Mark scheme
5(a)(i) It is a value that is invalid as an (array) index // not in the range of valid 1
(index) values
5(a)(ii) To test whether the current element / value at index matches the given / 1
search string / data / parameter
5(a)(iii) The value of FoundAt is only updated to the (current) index if it currently 1
stores the initial value / -1
//
FoundAt is not updated when it currently stores any other value than -1
5(b)(i) The loop continues after the (first instance) of the search value / string / 1
matching element has been found
Comparisons/tests continue to be made even if the search value / string /
matching element has been found
5(b)(ii) One mark per point 2
Construct: A conditional loop
Justification: The loop / search can be terminated as soon as the (first
occurrence of) SearchString / required value / required
string / matching element is found
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]
* 0000800000011 * DFD
11
(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.
…… [7]
* 0000800000012 * DFD
12
Mark scheme
6(a) Number: Any number where the first two digits sum to 5 / 15 and the 2
last three digits are 623
Explanation: The remainder is the same / 3 //
The sum of the (first four) digits is the same / 13
6(b) Example solution – conversion of Number to a string 7
FUNCTION Generate(Number : INTEGER) RETURNS INTEGER
DECLARE Total, Index, CheckDigit : INTEGER
DECLARE NumString : STRING
Total ← 0
NumString ← NUM_TO_STR(Number)
FOR Index ← 1 TO LENGTH(NumString)
Total ← Total + STR_TO_NUM(MID(NumString, Index,
1))
NEXT Index
CheckDigit ← Total MOD 10
Number ← Number * 10 + CheckDigit
// NumString ← Numstring & NUM_TO_STR(CheckDigit)
RETURN Number // STR_TO_NUM(NumString)
ENDFUNCTION
Mark as follows:
1 Function heading, parameters return type and ending
2 Initialise Total
3 Convert Number to a string and loop for length of converted Number
4 attempt to form sum of digits in a loop
5 completely correct sum of digits in a loop
6 Calculate CheckDigit
7 Add CheckDigit to original number multiplied by 10 and return number
//
Convert CheckDigit to a character and appended to NumString and
then convert to a number and return
6(b) Example Solution – no conversion to string
FUNCTION Generate(Number : INTEGER) RETURNS INTEGER
DECLARE Total, CheckDigit, Remainder, Num: INTEGER
Num ← Number
Total ← 0
WHILE Num > 0
Remainder ← Num MOD 10
Num ← Num DIV 10
Total ← Total + Remainder
ENDWHILE
CheckDigit ← Total MOD 10
Number ← Number * 10 + CheckDigit
RETURN Number
ENDFUNCTION
Mark as follows:
1 Function heading, parameters return type and ending
2 Initialise Total
3 Loop while Num > 0
4 attempt to use MOD and DIV to sum successive digits in Number
5 completely correct sum of digits
6 Calculate CheckDigit
7 Add CheckDigit to original number and return number
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]
* 0000800000013 * DFD
13
(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]
* 0000800000014 * DFD
14
Mark scheme
7(a) 5
One mark for each:
1 Label A1 | X1 added on line from S1 to state labelled S2
2 States S3, S4 and S5 labelled
3 Line from S2 to S5 with event label A4|X4
4 Lines from S3 with correct event labels including 'loop' label
5 Lines from S4 with correct event labels including 'loop'
7(b) 5
One mark per point:
1 All boxes correctly labelled
2 Iteration arrow
3 Parameter to Restart
4 Return value from Modify and parameter to Final
5 BYREF parameter to Update
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
* 0000800000015 * DFD
15
(a) Write efficient pseudocode for the module OKToBorrow()
…… [7]
* 0000800000016 * DFD
16
(b) A second module is defined:
Module Description
• called with two parameters of type STRING representing a
StudentID and a BookID
ReturnBook()
• searches the array for the relevant loan record
• when found, sets OnLoan to FALSE and returns TRUE
• if a loan record is not found, or the book has already been returned, then returns FALSE
Write efficient pseudocode for the module ReturnBook()
Assume that each student is only allowed to borrow each book only once. That means that there will be no more than one loan record for a given combination of student and book.
* 0000800000017 * DFD
17
…… [8]
(c) It is decided to introduce a system of fines for books that have been borrowed for too long.
Two new requirements are defined:
1. Each loan has a maximum length, represented as a number of days.
2. Each book in the library will be assigned one of three categories. Each category has a different maximum loan length.
Record structure and program design changes are needed to meet these two requirements.
Outline the changes that are necessary to meet the two requirements.
…… [2]
DFD
18
DFD
19
* 0000800000020 * DFD
20
Mark scheme
8(a) Example solution: 7
PROCEDURE OKToBorrow(ThisStudentID : STRING)
DECLARE Index, Count : INTEGER
CONSTANT Max = 5
Count ← 0
Index ← 1 / 0
WHILE Index <= 5000 / Index <= 4999 AND Count < Max
IF Loan[Index].StudentID = ThisStudentID AND __
Loan[Index].OnLoan =
TRUE THEN
Count ← Count + 1
ENDIF
Index ← Index + 1
ENDWHILE
IF Count < Max THEN
OUTPUT "Student may borrow another book"
ELSE
OUTPUT "Student may not borrow another book"
ENDIF
ENDPROCEDURE
Mark as follows:
1 Procedure heading, parameter and ending
2 Loop through all elements in Loan array
3 ... terminating if Max reached
4 Test for correct StudentID field in a loop
5 ... and that OnLoan = TRUE in a loop
... if so, then increment Count in a loop
6 Output an appropriate message in both cases after the loop
8(b) Example solution: 8
FUNCTION ReturnBook(ThisStudentID, ThisBookID : STRING)
RETURNS BOOLEAN
DECLARE Index : INTEGER
Index ← 1
WHILE Index < 5001
IF Loan[Index].StudentID = ThisStudentID AND __
Loan[Index].BookID = ThisBookID THEN
IF Loan[Index].OnLoan = TRUE THEN // Not
returned
Loan[Index].OnLoan ← FALSE // Mark as
returned now
RETURN TRUE //Found and not already returned
ELSE
RETURN FALSE // Found and already returned
ENDIF
ENDIF
Index ← Index + 1
ENDWHILE
RETURN False // loan not found
ENDFUNCTION
Mark as follows:
1 Loop through all elements in Loan array
2 ...and book loan not found
3 Attempt to reference an individual data item in a loop
4 Correct test for StudentID and correct BookID in a loop
5 … If book not returned yet, then set OnLoan field to FALSE
6 RETURN TRUE if book loan Found and not already returned
7 RETURN FALSE if book loan Found and loan already returned
8 RETURN FALSE if book loan not found
Alterantive example solution – not immediate return
FUNCTION ReturnBook(ThisStudentID, ThisBookID : STRING)
RETURNS BOOLEAN
DECLARE Index : INTEGER
DECLARE Found, OK : BOOLEAN
Index ← 1
Found ← FALSE
OK ← TRUE
8(b) WHILE Index < 5001 AND NOT Found
IF Loan[Index].StudentID = ThisStudentID AND __
Loan[Index].BookID = ThisBookID THEN
Found ← TRUE
IF Loan[Index].OnLoan = FALSE THEN // Already
returned
OK ← FALSE
ELSE
Loan[Index].OnLoan ← FALSE // Mark as
returned now
ENDIF
ENDIF
Index ← Index + 1
ENDWHILE
RETURN Found AND OK
ENDFUNCTION
8(c) Award marks for reference to following design features: 2
Change to existing Record:
1 Store date due back as a new data item / in the loan record
2 Store date of loan and the loan length category as new data items / in the
loan record
Max 1
New Record
3 New Records with Category (and Loan length field)
Change to Program:
4 (Use the loan length category of a book to) calculate the date due date
5 Compare due date with today’s date (to check if overdue / to calculate
fine)
6 Map loan length category to length of loan / date due back
Max 1
Max 2 marks
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/21 October/November 2025 mark scheme?+
On this page, free: the mark scheme for AS & A Level Computer Science 9618/21, October/November 2025 (9618_w25_ms_21), and the question paper (9618_w25_qp_21), to read or download, with each question's marking points written out underneath.
How many marks is 9618/21 out of?+
Computer Science 9618/21 for October/November 2025 is out of 75 marks, with 2 hours to answer it.
Can I get my 9618/21 answers marked?+
Yes. Upload your answers to 9618/21/O/N/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.