Past paper – A Level Computer Science (9618)
Cambridge International AS & A Level · 9618
Computer Science · Paper 22
Oct/Nov 2025 · 9618/22/O/N/25
Answer on paper, open each mark scheme and give yourself marks, then open the Summary.
Question text
1
(a) The table contains pseudocode examples.
Each example may contain statements that relate to one or more of:
•
selection
•
iteration (repetition)
•
subroutines (procedures or functions).
Complete the table by placing one or more ticks (‘3’) in each row.
Pseudocode example
Selection
Iteration
Subroutine
IF Status = FALSE THEN
FOR Count
1 TO 20
CALL Reset(Count)
NEXT Count
ENDIF
TRUE
OTHERWISE : Status
WHILE AllDone() = TRUE
'X'
30 : NextChar
[4]
(b) Complete the table by giving the appropriate data type.
Variable
Example data value
Data type
Result
5.42
MonthLetter
"JFMAMJJASOND"
Birthday
15/11/2009
[3]
(c) Evaluate each expression in the table by using the data values shown in (b).
Write ‘ERROR’ if the expression contains an error.
Expression
Evaluates to
INT(Result) + 1 > 6
NUM_TO_STR(LENGTH(MonthLetter))
NUM_TO_STR(Result + "3.2")
MID(MonthLetter, MONTH(Birthday) — 2, 1)
[4]
ĬÕĊ®Ġ´íÈõÏĪÅĊÞù¸þ×
Question text
2
Data is a global 1D array containing 20 elements of type REAL
An algorithm will:
•
input a sequence of real values, one at a time
•
assign each value to consecutive array elements, starting from index 1
•
end when the value 99.9 is input, or all 20 elements have been assigned (the value 99.9 must
not be stored in the array).
Complete the program flowchart to represent the algorithm:
START
END
[5]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊÞû¸þ×
Question text
3
A text file OldFile.txt contains IDs, names and email addresses for members of a club. Three
information items are stored for each member and each item is stored on a separate line.
The example shows the information for the first two members in the first six lines of the file:
Line in file
Information item
Example data
"AB1234"
1
member 1 ID
"Freddie Jones"
2
member 1 name
"[email protected]"
3
member 1 email address
"BC2345"
4
member 2 ID
"Sue Smith"
5
member 2 name
"[email protected]"
6
member 2 email address
The member ID string is always two letters followed by four digits.
The file design is to be changed so that information for each user is stored as a single line of the
file, with the character '\' used as a separator between data items.
For example, the single line for member 1 will be:
"AB1234\Freddie Jones\[email protected]"
An algorithm will produce a new file NewFile.txt from the contents of OldFile.txt
Assume:
•
LineX, LineY and LineZ are of type STRING and are used to store the three items of
information for each member
•
NewString is a temporary variable of type STRING
•
OldFile.txt exists and contains valid data.
(a) The algorithm to create the new file is expressed in steps.
Complete the following numbered steps:
Step 1 :
open the file … in …
Step 2 :
open the file … in …
Step 3 :
read a line from … and store in …
Step 4 :
read a line from … and store in …
Step 5 :
read a line from … and store in …
Step 6 :
set NewString to …
Step 7 :
write NewString to …
Step 8 :
repeat from step … until …
Step 9 :
close both files.
[6]
ĬÕĊ®Ġ´íÈõÏĪÅĊàù¸Ā×
,
,
(b) The character '\' has been chosen as a separator.
Explain why this is a suitable character.
…
… [1]
(c) Two new information items are to be stored for each member. Both new items are encrypted;
they can each contain any character (including '\') and can be of any length up to a
maximum of 99 characters.
For example:
Information item
Example data
"AB1234"
member 1 ID
"Freddie Jones"
member 1 name
"[email protected]"
member 1 email address
"En/98&*(|?\/D7iP"
member 1 new information 1
"23\CoboL"
member 1 new information 2
Explain the additional file design changes needed so that:
•
all the information items for each member are stored on a single line of NewFile.txt
•
it is possible to extract each information item after the line is read.
Assume the '\' character is not used in any email address.
…
…
…
…
…
Question text
4
A quiz has nine questions. There are:
•
five easy questions each worth 3 points
•
four hard questions each worth 5 points.
At the end of the quiz the points for each correctly answered question are added to give a total
score.
A check is made to test that the total score is valid using a 1D array CheckTotal of type BOOLEAN.
Each index value of the array represents a possible total score. The corresponding element value
is TRUE if the index value represents a valid total score and FALSE otherwise.
The first nine rows of the array are:
Index
Element
Comment
value
value
TRUE
0
valid total score (no correct answers)
FALSE
1
invalid total score
FALSE
2
invalid total score
TRUE
3
valid total score (one 3-point question correct)
FALSE
4
invalid total score
TRUE
5
valid total score (one 5-point question correct)
TRUE
6
valid total score (two 3-point questions correct)
FALSE
7
invalid total score
TRUE
8
valid total score (one 3-point question and one 5-point question correct)
For example, a total score of 6 points is valid; the value of the array element at index value 6 is TRUE
(a) Write pseudocode to declare CheckTotal and to set all elements of the array to FALSE
All variables used must be declared.
…
…
…
…
…
…
…
… [4]
ĬÙĊ®Ġ´íÈõÏĪÅĊÝûµþ×
,
,
(b) The pseudocode represents an algorithm to set the appropriate elements of the array to TRUE
Complete the pseudocode:
DECLARE EasyQ, HardQ : INTEGER
… TO 15 STEP …
FOR EasyQ
0 TO … STEP …
FOR HardQ
TRUE
CheckTotal[ … ]
NEXT HardQ
NEXT EasyQ
[5]
(c) The array elements have been assigned the required values.
A module ValidateScore() will take an integer value representing a total score as a
parameter. It will return TRUE if the total score is valid, or FALSE if it is not valid.
Describe the algorithm for ValidateScore() using four steps.
Do not use pseudocode in your answer.
Step 1 …
…
Step 2 …
…
Step 3 …
…
Question text
5
A program is developed to satisfy a specific customer requirement.
The project follows a program development life cycle model. This model divides the development
process into several different stages.
(a) The table lists some of the development activities.
Complete the table by writing the name of the life cycle stage for each activity:
Activity
Name of life cycle stage
a structure chart is produced
a program is modified to allow it to run on new hardware
the programmer identifies the customer’s requirements
an Integrated Development Environment (IDE) provides
context-sensitive help such as ‘auto-complete’
[4]
(b) Alpha and beta testing has been completed. The final testing stage is carried out by the
customer.
Identify this final testing stage.
… [1]
ĬÙĊ®Ġ´íÈõÏĪÅĊßûµĀ×
,
,
ĬÛĊ®Ġ´íÈõÏĪÅĊßùµĀ×
Question text
6
A string function Compare() will compare two strings.
The function will:
•
take four parameters:
○ two strings, String1 and String2
○ a character, Position, to indicate whether String1 will be compared with the start
('s'), or the end ('e') of String2
○ a Boolean, CaseMatters, to indicate whether an upper case character and lower case
character (for example, 'A' and 'a') are regarded as different (TRUE), or as the same
(FALSE)
•
return FALSE if String2 has fewer characters than String1
•
return TRUE if the comparison is true, otherwise return FALSE
For example:
Parameter
Return
value
String1
String2
CaseMatters
Position
TRUE
"Cat"
"Catalogue"
TRUE
's'
FALSE
"CAT"
"Catalogue"
TRUE
's'
TRUE
"CAT"
"Catalogue"
FALSE
's'
FALSE
"Cat"
"Catalogue"
TRUE
'e'
TRUE
"GUE"
"Catalogue"
FALSE
'e'
FALSE
"Catalogue"
"Cat"
TRUE
's'
ĬÙĊ®Ġ´íÈõÏĪÅĊÞû·þ×
,
,
Write pseudocode for the function Compare()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
7
The structure chart shows part of a program design:
Convert
Count
P2
T1
Key
Analyse
Update
Sort
(a) Explain the meaning of the curved arrow symbol in this structure chart.
…
…
…
… [2]
(b) The program designer has noted that:
•
Count is the number of elements in an array
•
T1 is a value representing the number of elements in an array that have been modified
•
Key is of type STRING
Write the pseudocode module headers for analyse, update and sort.
Analyse:
…
…
Update:
…
…
Sort:
…
…
[4]
ĬÙĊ®Ġ´íÈõÏĪÅĊàû·Ā×
Question text
8
A program is being developed to manage student book loans from a college library.
The programmer has defined a record type to define each loan.
The 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 7000 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 a program module:
Module
Description
•
called with a parameter of type STRING representing a
StudentID
•
counts the number of books currently on loan to the
specified student
CountLoans()
•
counts the number of books that the student has already
returned
•
output both counts together with a suitable message
ĬÕĊ®Ġ´íÈõÏĪÅĊßú¶Ă×
,
,
(a) Write pseudocode for module CountLoans()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…