Programming – A Level Computer Science (9618)

85 questions · page 1 of 6 · 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/M/J/25 · Question 1May/June 2025Paper 2116 marks
Loading question…
Question text

1
A program is being developed to help the manager of a shop control the stock.
(a) An identifier table has been used during the design stage.
Complete the identifier table:
Example value
Explanation
Variable name
Data type
a category of stock
"Fruit"
that is sold in the shop
when an item was
20/02/2025
sold
12.67
the cost of an item
to indicate if an item is
TRUE
in stock
[4]
(b) A module Sales() is part of the stock control program.
The table contains pseudocode extracts from the module Sales()
Each extract may include all or part of:
•
assignment
•
selection
•
iteration (repetition).
Complete the table by placing one or more ticks (✓) in each row:
Pseudocode extract
Assignment
Selection
Iteration
CalculateTotal()
Result
WHILE IsClosed
REPEAT
INPUT Value
UNTIL Sales[4] > Value
IF Sales[Current] <= 150 THEN
TRUE
Discount
ENDIF
CASE OF Option
[5]
ĬÕĊ®Ġ´íÈõÏĪÅĊÞú¸þ×
,
,
(c) Decomposition has been used to design the program to help the shop manager control the
stock.
Describe decomposition.
…
…
…
…
…
… [3]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊÞü¸þ×

Advertisement
14
9618/21/M/J/25 · Question 2May/June 2025Paper 2110 marks
Loading question…
Question text

2
A program is being developed to calculate the pay of employees working for a company.
A function CalculateBonus() calculates bonus pay based on the value of sales.
Bonus pay is calculated as shown in the table.
Value of sales
Bonus pay
(in dollars)
(in dollars)
below 2000
0
between 2000 and 4000 inclusive
10
above 4000
100
A flowchart for the function CalculateBonus() has been designed.
START
Set BonusPay to 0
INPUT
ValueOfSales
Is
NO
ValueOfSales
> 4000 ?
YES
Is
NO
ValueOfSales
Set BonusPay to 10
> = 2000 ?
YES
Set BonusPay to 100
RETURN BonusPay
END
ĬÕĊ®Ġ´íÈõÏĪÅĊàú¸Ā×
,
,
(a) The flowchart contains logic errors.
One logic error is that BonusPay will not be set to 10 although the ValueOfSales input is
between 2000 and 4000 inclusive.
(i)
Explain why this error occurs.
…
… [1]
(ii)
Explain how this error could be corrected.
…
… [1]
(b) There are different ways to reduce the risk of errors when developing the new program, such
as the use of constants.
(i)
State a value that could be replaced by a constant in the function CalculateBonus()
… [1]
(ii)
Explain how the use of constants helps to reduce the risk of programming errors.
…
…
…
… [2]
(iii)
One other way that can reduce the risk of errors when writing the program is the use of
library routines.
Explain how library routines can reduce the risk of programming errors.
…
… [1]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊàü¸Ā×
,
,
(c) All the logic errors have been corrected, and the program has been coded.
Identify and describe two other types of error that the program could contain.
Type of error …
Description …
…
…
Type of error …
Description …
…

15
9618/21/M/J/25 · Question 3May/June 2025Paper 218 marks
Loading question…
Question text

3
A student has been asked to create a simple guessing game program. This program will generate
a random integer value between 1 and 100. It will then repeatedly prompt the user to input an
integer value until they input the randomly generated value.
The student has written a structured English description:
step 1 – randomly generate an integer value between 1 and 100 inclusive
step 2 – prompt the user to input an integer value
step 3 – output an appropriate message if the value input was too high; then repeat from step 2
step 4 – output an appropriate message if the value input was too low; then repeat from step 2
step 5 – output an appropriate message if the value input was the same value that was randomly
generated; then end the program.
Write a pseudocode algorithm from this structured English description.
Assume no input validation is needed.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [8]
ĬÛĊ®Ġ´íÈõÏĪÅĊÝúµþ×

Advertisement