Programming – A Level Computer Science (9618)

153 questions · page 1 of 11 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
1
9618/21/M/J/26 · Question 1May/June 2026Paper 212 marks
Loading question…
Question text

1
Study this pseudocode:
3 TO 12 STEP 3
FOR i
OUTPUT i, i * i
NEXT i
(a) Identify the type of construct used in this pseudocode.
… [1]
(b) State how many iterations are performed by this pseudocode.
… [1]
© Cambridge University Press & Assessment 2026

2
9618/21/M/J/26 · Question 2May/June 2026Paper 217 marks
Loading question…
Question text

2
A washing machine contains:
•
two trays for the washing powder
•
a user interface display
•
five sensors.
The washing machine control program includes the following variables:
variable
description
MainsOn
TRUE when the mains power is on
WaterOn
TRUE when the water supply to the machine is turned on
DisplayOn
TRUE when the user interface display is active
Tray1
TRUE when it detects washing powder in tray 1
Tray2
TRUE when it detects washing powder in tray 2
(a) (i)
Identify the data type used for the five variables.
… [1]
(ii)
The display is only active when both the mains power is on and the water supply is
turned on.
Complete the pseudocode statement.
…
DisplayOn
[1]
(iii)
The washing machine control program will start when a new variable WashStart is
assigned the value TRUE
WashStart is assigned the value TRUE when the mains power is switched on and
there is washing powder in tray 1 or tray 2 or both trays.
Write the pseudocode statement for the given description.
…
… [3]
© Cambridge University Press & Assessment 2026
,
,
(b) The user will select from three possible wash options.
The pseudocode for the washing machine program contains a procedure WashCycle()
PROCEDURE WashCycle()
// declaration of variables has been omitted
// TimeSoFar is a global variable which changes
// as the procedure is executed
FALSE
Finished
0.0
TimeSoFar
OUTPUT "Option (1/2/3)"
INPUT OptionNumber
CASE OF OptionNumber:
// WashTime is the total wash time in minutes
60
1 : WashTime
90
2 : WashTime
120
3 : WashTime
ENDCASE
WHILE Finished = FALSE
WashTime – INT(TimeSoFar)
TimeRemaining
ENDWHILE
ENDPROCEDURE
(i)
The programmer uses an Integrated Development Environment (IDE) to develop and
run the washing machine program.
State the IDE feature to display the current value for any variable during the execution
of the program.
… [1]
© Cambridge University Press & Assessment 2026
,
,
(ii)
When option 3 is selected, the programmer interrupts execution when the TimeSoFar
is 17.6 minutes.
State the current value for TimeRemaining
… [1]
© Cambridge University Press & Assessment 2026

3
9618/21/M/J/26 · Question 5May/June 2026Paper 215 marks
Loading question…
Question text

5
Electric light bulbs are advertised online with the price showing:
$1.75 each or 20 bulbs for $30.00
A pseudocode function BulbCost()
•
takes the quantity of bulbs purchased as its single parameter
•
returns the total cost in dollars.
Pseudocode for the main program:
•
inputs the number of bulbs purchased
•
returns the total cost from the function BulbCost()
•
outputs the total cost.
(a) Write pseudocode for the function BulbCost()
…
…
…
…
…
…
…
…
…
… [4]
(b) The main program accepts a user input for the quantity of bulbs purchased and calls
function BulbCost()
Complete the pseudocode for the main program.
// Main program
DECLARE NumberPurchased : INTEGER
DECLARE TotalCost : REAL
OUTPUT "How many bulbs? "
INPUT NumberPurchased
…
TotalCost
OUTPUT '$' , TotalCost
// end main program
[1]
© Cambridge University Press & Assessment 2026
,
,
© Cambridge University Press & Assessment 2026

Advertisement
4
9618/21/M/J/26 · Question 6May/June 2026Paper 2112 marks
Loading question…
Question text

6
Fence parts are manufactured by a number of similar machines. The length of the part must fall
within a certain range. Parts not within the length range are rejected.
The data for each rejected part forms a data packet made up of three data items, each separated
by the ‘/’ character delimiter. The format of a data packet is:
<length>/<machine ID>/<description of the fault>
•
The length is 3 digits (in millimetres).
•
The machine ID is a single character (‘A’, ‘B’, or ‘C’).
•
The description of the fault is a variable length string.
A pseudocode program will process the data for several data packets.
The program contains the statement:
"563/B/the fence length is too long"
DataPacket
(a) Complete the two pseudocode expressions which extract the appropriate data item.
…
PartLength
…
MachineID
[2]
(b) The program will create a module RejectDescription() to return the fault description.
Write the pseudocode for the module RejectDescription()
…
…
…
…
…
… [4]
© Cambridge University Press & Assessment 2026
,
,
(c) The data packets for all rejected parts are saved in this format in a text file Rejects.txt.
The file stores one data packet per line.
Write pseudocode to:
•
find all the rejected parts with a length greater than 560 millimetres and that were
produced on machine ‘B’ or machine ‘C’
•
output the description for each matching rejected part.
Your pseudocode will include a module call to RejectDescription() and the answers
given for 6(a).
…
…
…
…
…
…
…
…
…
…

5
9618/21/M/J/26 · Question 8May/June 2026Paper 216 marks
Loading question…
Question text

8
Global array MyData contains the values shown.
Study the pseudocode algorithm and array MyData
FUNCTION MyTrace(Target : INTEGER) RETURNS INTEGER
DECLARE LeftPointer, RightPointer, MidPointer : INTEGER
1
LeftPointer
MyData
RightPointer
15
WHILE LeftPointer <= RightPointer
2
1
MidPointer
(LeftPointer + RightPointer) DIV 2
8
2
IF MyData[MidPointer] = Target THEN
9
3
OUTPUT "Found " & NUM_TO_STR(MidPointer)
12
4
RETURN MidPointer
13
5
ELSE
15
6
IF Target > MyData[MidPointer] THEN
18
7
LeftPointer
MidPointer + 1
19
8
ELSE
20
9
RightPointer
MidPointer - 1
23
10
ENDIF
25
ENDIF
11
ENDWHILE
26
12
OUTPUT "Not found"
39
13
RETURN -1
38
14
ENDFUNCTION
40
15
© Cambridge University Press & Assessment 2026
,
,
(a) Complete the trace table for the function MyTrace when the following pseudocode
statement is executed.
MyTrace(15)
Result
LeftPointer
RightPointer
MidPointer
[4]
(b) Give the output.
… [1]
(c) Give the value assigned to Result
… [1]

6
9618/22/M/J/26 · Question 1May/June 2026Paper 2227 marks
Loading question…
Question text

1
A program is being developed to control a simple alarm system to be used in a house. The alarm
has a control panel with a keypad and a screen to display text.
The keypad consists of 36 character keys:
•
26 upper‑case letter keys, allowing A to Z to be entered
•
10 digit keys, allowing 0 to 9 to be entered.
(a) When the alarm system is initially installed, a password must be created. When the
password is initially entered, it is checked to ensure that it follows a set of validation rules. It
is then permanently stored in the alarm system.
For a password to be valid it must follow these validation rules:
Rule 1: contain between six and eight characters inclusive.
Rule 2: contain at least one letter and one digit.
Rule 3: each character can only occur once.
The global variable Pass is used to store the password entered.
(i)
Complete the pseudocode to declare the variable to be used to hold the password.
DECLARE Pass : …
[1]
(ii)
Complete the pseudocode to check that a password contains between six and eight
characters inclusive (rule 1).
IF … (Pass) < 6 OR … (Pass) > … THEN
OUTPUT "Error"
OUTPUT "The password has to contain between 6 and 8 characters."
ENDIF
[2]
© Cambridge University Press & Assessment 2026
,
,
(iii)
Complete the pseudocode to check that a password entered contains at least one letter
and one digit character (rule 2).
DECLARE Index : INTEGER
DECLARE Character : CHAR
DECLARE LetterFlag, DigitFlag : …
FALSE
DigitFlag
…
LetterFlag
1 TO … (Pass)
FOR Index
… (Pass, … , … )
Character
IF … (Character) = TRUE THEN
…
DigitFlag
ELSE
…
LetterFlag
ENDIF
NEXT Index
IF … (LetterFlag AND DigitFlag) THEN
OUTPUT "Error"
OUTPUT "Password needs at least one letter and one digit."
ENDIF
[7]
(b) A state‑transition diagram is being created as part of the design process for the module,
which will control the alarm system once it has been successfully installed. Two of the states
already identified are that the alarm is in:
•
standby mode
•
on mode (alarm system is active).
(i)
Identify two other states that should be part of the state‑transition diagram.
1 …
2 …
[2]
© Cambridge University Press & Assessment 2026
,
,
(ii)
Two events that will cause a change of state are:
•
entering the password when the alarm system is in standby mode
•
entering the password when the alarm system is in on mode.
Identify three other events that would cause a change of state in the state‑transition
diagram for the alarm system.
1 …
2 …
3 …
[3]
(c) The validation rules from 1(a) are given again:
For a password to be valid it must follow these validation rules:
Rule 1: contain between six and eight characters inclusive.
Rule 2: contain at least one letter and one digit.
Rule 3: each character can only occur once.
Complete the table with test data that could be used to test the validation rules.
Each example of test data given must:
•
be invalid for the specific rule being tested
•
be valid for the other two rules not being tested
•
test a different aspect of the rule b

7
9618/22/M/J/26 · Question 5May/June 2026Paper 2210 marks
Loading question…
Question text

5
A programmer has defined a global 1D array Numbers of type INTEGER, which can store 1000
integers. The lower bound of the array Numbers is set to 1. Each element of the array has been
initialised with a random integer in the range 200 to 99 999.
The programmer has written a bubble sort algorithm to sort the array Numbers into
ascending order.
Study algorithm A.
Assume all the variables have been correctly declared.
algorithm A:
1 TO 999
//Outer Loop
FOR LoopCounter
1 TO 999
//Inner Loop
FOR Index
IF Numbers[Index] > Numbers[Index + 1] THEN
//Start of block to swap neighbouring elements in the array
Numbers[Index]
Temp
Numbers[Index + 1]
Numbers[Index]
Temp
Numbers[Index + 1]
//End of block to swap neighbouring elements in the array
ENDIF
NEXT Index
NEXT LoopCounter
(a) Describe the change that would have to be made to the bubble sort algorithm (algorithm A)
so that the Numbers array would be sorted into descending order.
…
… [1]
© Cambridge University Press & Assessment 2026
,
,
(b) The programmer rewrites the bubble sort algorithm to make it more efficient.
Study algorithm B.
Assume all the variables have been correctly declared.
algorithm B:
999
Boundary
REPEAT
//Outer Loop
TRUE
NoSwaps
1 TO Boundary
//Inner Loop
FOR Index
IF Numbers[Index] > Numbers[Index + 1] THEN
//Start of block to swap neighbouring elements in the array
Numbers[Index]
Temp
Numbers[Index + 1]
Numbers[Index]
Temp
Numbers[Index + 1]
//End of block to swap neighbouring elements in the array
FALSE
NoSwaps
ENDIF
NEXT Index
Boundary ‑ 1
Boundary
UNTIL NoSwaps = TRUE
(i)
Explain why the second bubble sort algorithm (algorithm B) is more efficient than the
first bubble sort algorithm (algorithm A). Your answer must refer to both inner and
outer loops.
…
…
…
…
…
…
…
…
… [4]
(ii)
State the situation that will result in the outer loop iterating for the minimum number of
times when the second bubble sort algorithm (algorithm B) is used.
…
… [1]
© Cambridge University Press & Assessment 2026
,
,
(c) The programmer has defined a new procedure:
PROCEDURE Swap(Num1 : INTEGER, Num2 : INTEGER)
DECLARE Temp : INTEGER
Num1
Temp
Num2
Num1
Temp
Num2
END

8
9618/22/M/J/26 · Question 6May/June 2026Paper 2218 marks
Loading question…
Question text

6
A program is being developed to encrypt a message.
The following terms are used in the encryption technique to be used:
term
definition
plain text
The original message before it is encrypted.
cipher text
The encrypted version of the plain text.
The encryption method to be used is based on the algorithm for the Caesar Box Cipher. All plain
text messages to be encrypted must be 25 characters in length or less. If a message is less than
25 characters in length, then spaces are added to the end to make the padded plain text the
required length.
A square grid of five columns and five rows is used. The padded plain text message is put into
the grid row by row. The cipher text is obtained by reading the grid column by column.
For example:
plain text: This is a message
The number of characters in the original plain text, including spaces, is 17.
plain text with added spaces at the end: This∆is∆a∆message∆∆∆∆∆∆∆∆
The character ∆ is used to indicate a space in the padded plain text.
The grid filled, row by row, with the padded plain text.
T
h
i
s
∆
i
s
∆
a
∆
m
e
s
s
a
g
e
∆
∆
∆
∆
∆
∆
∆
∆
The cipher text is obtained by reading the grid column by column.
cipher text: Timg∆hsee∆i∆s∆∆sas∆∆∆∆a∆∆
The programmer has defined the first program module as:
module
description
•
user prompt for and input of plain text
•
check plain text contains between 1 and 25 characters inclusive
•
re‑input of plain text until it contains between 1 and 25 characters
AddPadding()
•
if required, additional space characters are added to the end of
the plain text to ensure it contains exactly 25 characters
•
return of amended plain text
© Cambridge University Press & Assessment 2026
,
,
(a) Write pseudocode for module AddPadding()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement
9
9618/23/M/J/26 · Question 1May/June 2026Paper 232 marks
Loading question…
Question text

1
Study the pseudocode.
1
i
REPEAT
OUTPUT i*i
i + 1
i
UNTIL i = 6
(a) Identify the type of programming construct used in the pseudocode.
… [1]
(b) State how many iterations are carried out by the pseudocode.
… [1]
© Cambridge University Press & Assessment 2026

10
9618/23/M/J/26 · Question 2May/June 2026Paper 236 marks
Loading question…
Question text

2
A control program is being developed for a robot floor vacuum cleaner. The settings for the robot
can be changed and include:
•
the strength of the suction (numerical values: 0, 1, 2, 3, 4 or 5)
•
the total vacuum cleaning time (a whole number of minutes).
The robot has a number of sensors.
The control program includes the variables:
variable
description
MainsOn
TRUE when the mains power is on
DisplayOn
TRUE when the user display is shown
TRUE when the program detects that the user has selected a non-zero value
Suction
for the strength of the suction
(a) Identify the data type used for the three variables.
… [1]
(b) Write a pseudocode statement to set the DisplayOn variable to TRUE when the mains
power is on.
…
…
… [1]
(c) When the robot is ready to move, the program assigns the value TRUE to a variable, Move
The control program contains the pseudocode logic expression:
MainsOn AND Suction
Move
Explain the pseudocode statement.
…
…
… [2]
© Cambridge University Press & Assessment 2026
,
,
(d) The pseudocode for the control program contains the procedure CleanProgram()
PROCEDURE CleanProgram()
// declaration of variables has been omitted
FALSE
Finished
OUTPUT "Total clean time (minutes)"
INPUT TotalCleanTime
OUTPUT "Suction strength (0,1,2,3,4,5)"
INPUT SuctionStrength
WHILE
Finished = FALSE
//
TimeSoFar is a global variable which changes
//
as the procedure is executed
//
TimeSoFar is the time the robot has been cleaning (in seconds)
TimeRemaining
TotalCleanTime – INT(TimeSoFar/60)
ENDWHILE
ENDPROCEDURE
(i)
When the program is under development and running, the programmer can temporarily
stop the execution at a set point in the program.
Identify this feature of the Integrated Development Environment (IDE).
… [1]
(ii)
The programmer runs the program.
•
The user is prompted and inputs the value 40 (total clean time in minutes).
•
The user is prompted and inputs the value 3 (for the suction strength).
•
The programmer interrupts its execution; the TimeSoFar is shown in a report
window as 125 (the cleaning time so far in seconds).
State the current value of TimeRemaining
… [1]
© Cambridge University Press & Assessment 2026

11
9618/23/M/J/26 · Question 5May/June 2026Paper 2311 marks
Loading question…
Question text

5
Data is stored about people who have attended a job interview. Each interview is held at one of
three office locations.
Each person’s data is stored as a data packet made up of four data items:
<initial><shortened surname><office code><summary of the interview>
•
The initial is a single character.
•
The shortened surname is the first five characters of the surname.
○ You can assume all surnames are at least five characters.
•
The office code is a single character ‘A’, ‘B’ or ‘C’.
•
The interview summary text is of variable length.
Example:
Peter Watkins was interviewed at office ‘B’. After the interview it was decided to invite him for a
second interview.
His data packet is stored by variable Applicant:
"PWatkiBSecond interview"
Applicant
(a) A pseudocode function InterviewSummary() will:
•
take the data packet as a single parameter
•
return the interview summary text.
Write the pseudocode for the function InterviewSummary()
…
…
…
…
…
… [4]
© Cambridge University Press & Assessment 2026
,
,
(b) The data for all interviews is saved in this format in a text file JobApps.txt
Each line of the file stores one data packet.
A procedure Search() is written to search for a particular applicant.
If the applicant is found, the program will output ‘Name found’, otherwise it will output ‘Name
not found’.
Complete the pseudocode for procedure Search()
PROCEDURE Search(Initial : CHAR, ShortSurname : STRING)
DECLARE ThisApplicant, ThisSurname : STRING
DECLARE ThisInitial : CHAR
DECLARE Found : BOOLEAN
OPENFILE "JobApps.txt" …
FALSE
Found
REPEAT
… "JobApps.txt", ThisApplicant
LEFT(ThisApplicant, 1)
ThisInitial
…
ThisSurname
IF ThisSurname = ShortSurname … THEN
…
OUTPUT "Name found"
ENDIF
UNTIL Found = TRUE …
IF Found = FALSE THEN
OUTPUT "Name not found"
ENDIF
…
ENDPROCEDURE
[7]
© Cambridge University Press & Assessment 2026

12
9618/23/M/J/26 · Question 8May/June 2026Paper 2319 marks
Loading question…
Question text

8
A warehouse stores stock in bins. A bin is a container which stores the stock items; each bin can
store many identical items. The warehouse is organised on three different levels – level 0 (ground
level), then level 1 and level 2. Each level has 120 bins, numbered 1 to 120.
A bin is identified by the level and a bin number. The data item stored for each bin is a Boolean
value; this indicates whether the bin is in use (contains stock items) or not in use (contains no
stock items).
(a) (i)
Complete the pseudocode to declare a 2D array Bins
DECLARE …
[2]
(ii)
A pseudocode module InactiveReport() will produce a report that will show:
•
a header for each level
•
the bin number for each bin that is not in use on that level
•
the total number of bins that are not in use on all levels.
The module is initially developed for only five bins on each level.
An example program output:
Level: ground floor
Shows:
Bin 1
Bin 3
• the header for each level
Level: 1
Bin 4
• a list of bin numbers for bins that are
not in use on that level
Level: 2
Bin 1
• the total number of bins not in use.
Bin 2
Bin 5
6 bins are not in use
© Cambridge University Press & Assessment 2026
,
,
Complete the pseudocode for the procedure InactiveReport()
Assume that the Bins array is a global variable and has already been populated
with data.
PROCEDURE InactiveReport()
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

13
9618/21/O/N/25 · Question 1Oct/Nov 2025Paper 2110 marks
Loading question…
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]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊßù¸þ×

Advertisement
14
9618/21/O/N/25 · Question 5Oct/Nov 2025Paper 216 marks
Loading question…
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]
ĬÛĊ®Ġ´íÈõÏĪÅĊÞûµĀ×

15
9618/21/O/N/25 · Question 6Oct/Nov 2025Paper 219 marks
Loading question…
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.
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement