Computer Science (2210) · May/June 2025 · Question paper 21
Cambridge Computer Science (2210) question paper for paper 21, May/June 2025 — 2210/21/M/J/25, file 2210_s25_qp_21.pdf.
Text of this paper
* 0000800000001 *
,
,
Cambridge O Level
¬O. 4mHuOªE_y5W
¬¢fzVªufv1xt3;
¥ 5ueUEEUEEUEU U
* 4 6 9 7 2 5 0 5 4 5 *
COMPUTER SCIENCE
Paper 2 Algorithms, Programming and Logic
2210/21
May/June 2025
1 hour 45 minutes
You must answer on the question paper.
No additional materials are needed.
INSTRUCTIONS
●
Answer all questions.
●
Use a black or dark blue pen. You may use an HB pencil for any diagrams or graphs.
●
Write your name, centre number and candidate number in the boxes at the top of the page.
●
Write your answer to each question in the space provided.
●
Do not use an erasable pen or correction fluid.
●
Do not write on any bar codes.
●
Calculators must not be used in this paper.
INFORMATION
●
The total mark for this paper is 75.
●
The number of marks for each question or part question is shown in brackets [ ].
●
No marks will be awarded for using brand names of software packages or hardware.
This document has 16 pages. Any blank pages are indicated.
DC (CJ) 353319
© UCLES 2025
[Turn over
2
Tick (ü) one box to identify the type of test to only check for the largest or smallest acceptable
value.
A
normal test data
B
abnormal test data
C
extreme test data
D
boundary test data
[1]
Four requirements for validating inputs and five types of validation check are given.
Requirement
Validation check
Date of birth must be between
01/01/1900 and 01/01/2010.
length check
DO NOT WRITE IN THIS MARGIN
(a) Draw one line from each requirement to the most appropriate validation check.
Not all validation checks will be used.
format check
Name has been entered.
range check
Password has exactly 12 characters.
check digit
Student ID must contain 2 letters followed
by a 4-digit number.
presence check
[4]
(b) Identify and describe one verification check that could be applied when a new password is
input into a system.
Verification check
Description
DO NOT WRITE IN THIS MARGIN
1
,
DO NOT WRITE IN THIS MARGIN
2
,
DO NOT WRITE IN THIS MARGIN
* 0000800000002 *
[3]
© UCLES 2025
ĬÍĊ®Ġ´íÈõÏĪÅĊÞû·þ×
ĬĢèù×ĞĜēÍċ÷ÎÀĊăăĕĂ
ĥÕąĕõĕĥµõąąąÅĕåĕåÕ
2210/21/M/J/25
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000003 *
3
,
3
,
The following pseudocode algorithm uses a count-controlled loop to read in 10 names and store
them in the array Names[]
1 TO 10
FOR Count
OUTPUT "Please enter a name"
INPUT Name
Name
Names[Count]
NEXT Count
Rewrite the algorithm in pseudocode, using a condition-controlled loop instead of a count-controlled
loop.
[4]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
© UCLES 2025
ĬÏĊ®Ġ´íÈõÏĪÅĊÞù·þ×
ĬĢçúÏĬĘģìíĊěĜò×ăĥĂ
ĥÕõÕµõąÕĥõÕąÅõÅÕµÕ
2210/21/M/J/25
[Turn over
4
,
A telephone number with 13 characters is input. The first character is a ‘+’, followed by a 2-digit
country code, for example:
+20xxxxxxxxxx where 20 is the country code and x is a digit between 0 and 9 inclusive.
The algorithm includes checks for the country codes: 44 for the UK and 20 for Egypt.
(a) Write an algorithm using pseudocode to:
•
•
•
•
input the telephone number
extract the 2-digit country code
output the matching country
output ‘Unknown’ if there is no matching country.
DO NOT WRITE IN THIS MARGIN
4
,
DO NOT WRITE IN THIS MARGIN
* 0000800000004 *
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
[5]
© UCLES 2025
ĬÍĊ®Ġ´íÈõÏĪÅĊàû·Ā×
ĬĢçûÏĢĦĦÏóāĔºÎõēčĂ
ĥĥåÕõõąõąÕåąąõĥÕåÕ
2210/21/M/J/25
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000005 *
5
,
,
(b) Explain how you could change the algorithm to repeatedly prompt for the telephone number
until the number entered is 13 characters in length.
Any code used must be fully explained.
DO NOT WRITE IN THIS MARGIN
[3]
DO NOT WRITE IN THIS MARGIN
5
Two library routines used in programming are MOD and DIV.
State the purpose of each of the library routines.
Give one example pseudocode statement for each of the library routines.
MOD purpose
Example pseudocode
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DIV purpose
Example pseudocode
[4]
© UCLES 2025
ĬÏĊ®Ġ´íÈõÏĪÅĊàù·Ā×
ĬĢèü×ĨĪĖêąðÕĞæáēĝĂ
ĥĥÕĕµĕĥĕĕåõąąĕąĕµÕ
2210/21/M/J/25
[Turn over
An algorithm has been written in pseudocode to generate a random integer between 1 and 100
inclusive and store the value in N. The user enters a guess for the number and the algorithm
indicates whether the guess is higher or lower than the random number. The algorithm outputs
the number of guesses when the user has correctly guessed the random number.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
0
Counter
ROUND(RANDOM() * 99, 1) + 1
N
REPEAT
OUTPUT "Please enter a guess"
INPUT G
IF G > N
THEN
OUTPUT "The number is lower than your guess"
ELSE
IF G < N
THEN
OUTPUT "The number is lower than your guess"
ENDIF
Counter + 1
Counter
ENDIF
UNTIL G = N
OUTPUT "Well done, you took ", Guess, " attempts"
(a) Identify the line numbers of the four errors in the pseudocode and suggest a correction for
each error.
Error 1 line number
Correction
Error 2 line number
DO NOT WRITE IN THIS MARGIN
6
,
DO NOT WRITE IN THIS MARGIN
6
,
DO NOT WRITE IN THIS MARGIN
* 0000800000006 *
Correction
Correction
Error 4 line number
Correction
[4]
(b) Identify one method to make the algorithm maintainable.
Give an example.
[2]
© UCLES 2025
ĬÑĊ®Ġ´íÈõÏĪÅĊÝù¶þ×
ĬĢçüÜĞĂĐâĂýàþÎÄ»čĂ
ĥµõĕµµĥµÕÅÕąÅĕåÕĥÕ
2210/21/M/J/25
DO NOT WRITE IN THIS MARGIN
Error 3 line number
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000007 *
7
,
7
,
Consider the logic expression:
X = (A AND B) XOR (B OR NOT C)
(a) Draw a logic circuit for this logic expression.
Each logic gate must have a maximum of two inputs.
A
B
DO NOT WRITE IN THIS MARGIN
X
C
[4]
(b) Complete the truth table for the given logic expression.
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
Do not simplify the logic expression.
A
B
C
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
Working space
X
[4]
© UCLES 2025
ĬÓĊ®Ġ´íÈõÏĪÅĊÝû¶þ×
ĬĢèûÔĬþĠ×øôĩÚæĘ»ĝĂ
ĥµąÕõÕąÕŵąąÅõÅĕõÕ
2210/21/M/J/25
[Turn over
A bus company has set up a new database table called BUS to store details of the buses leaving
the main bus terminal.
RouteID
Destination
Stops
Driver
Time
Return
BC01
Town Centre
10
B Smith
9:00
Yes
BC02
The Fountain
5
A Patel
9:10
Yes
BC03
The Palace
9
B Hayes
9:28
No
BC04
City Park
12
W Gao
9:55
Yes
BC05
City Mall
9
R Hussein
10:10
No
BC06
Swan Lake
14
S Clarke
10:33
No
BC07
Guildhall Square
7
J Page
11:34
No
BC08
Sunset Quay
6
A Patel
12:01
Yes
BC10
Fort Worthington
15
E Carr
12:01
Yes
BC12
The Observatory
18
B Smith
13:27
No
BC14
East Seaport
11
B Scott
14:07
No
BC15
The Football Ground
12
J Page
14:46
Yes
BC19
The Cricket Ground
11
B Hayes
15:14
No
BC23
Temple Ruins
14
W Gao
16:16
No
BC27
The University
9
A Patel
16:45
No
(a) (i)
Identify one appropriate data type for the field Return
[1]
(ii)
DO NOT WRITE IN THIS MARGIN
,
State the reason for the data type chosen.
[1]
(b) Write the output from the structured query language (SQL) statement:
SELECT RouteID, Destination, Time
FROM BUS
DO NOT WRITE IN THIS MARGIN
8
DO NOT WRITE IN THIS MARGIN
8
,
DO NOT WRITE IN THIS MARGIN
* 0000800000008 *
[2]
© UCLES 2025
ĬÑĊ®Ġ´íÈõÏĪÅĊßù¶Ā×
ĬĢèúÔĢðĩäúûĢüĊ¶ëĕĂ
ĥąÕÕµÕąõåĕõąąõĥĕĥÕ
2210/21/M/J/25
DO NOT WRITE IN THIS MARGIN
WHERE Driver = "A Patel";
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000009 *
9
,
,
(c) Complete the SQL statement to display only the destination of the buses that have a return.
SELECT
[3]
9
The variables A and B are used in a program. A holds a whole number and B holds text.
(a) Write pseudocode statements to declare the variables A and B
[2]
(b) The function Odds(X) returns ‘Odd’ if the value of X is an odd number and returns ‘Even’ if
the value of X is an even number.
Write pseudocode statements to:
•
•
define the function
call the function using parameter A and store the return item in variable B
Function definition
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
Function call
[6]
© UCLES 2025
ĬÓĊ®Ġ´íÈõÏĪÅĊßû¶Ā×
ĬĢçùÜĨôęÕĀĆçàòĢëĥĂ
ĥąåĕõµĥĕµĥåąąĕąÕõÕ
2210/21/M/J/25
[Turn over
,
10 The flowchart represents an algorithm to calculate grades.
START
INPUT
Score
Yes
Grade
No
IS Score
>= 60 ?
Yes
Grade
No
Yes
Grade
No
Grade
"D"
OUTPUT "You
achieved a ", Grade
STOP
© UCLES 2025
ĬÑĊ®Ġ´íÈõÏĪÅĊÞù¸þ×
ĬĢåúÙĤøïÞñôÌĘČÒēĝĂ
ĥÕµĕµÕåõąåõÅąÕĥĕÕÕ
"A"
DO NOT WRITE IN THIS MARGIN
IS Score
>= 80 ?
"B"
"C"
2210/21/M/J/25
DO NOT WRITE IN THIS MARGIN
IS Score
>= 40 ?
DO NOT WRITE IN THIS MARGIN
10
,
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000010 *
11
,
,
(a) Complete the trace table for the algorithm, using the input data:
21, 46, 63, 91, 12
Score
Grade
OUTPUT
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000011 *
[3]
(b) Explain how the flowchart can be changed to produce the correct output.
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
[4]
© UCLES 2025
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¸þ×
ĬĢæùÑĦüÿÛćýýÄôĆēčĂ
ĥÕÅÕõµÅĕĕÕåÅąµąÕÅÕ
2210/21/M/J/25
[Turn over
The one-dimensional (1D) array CompetitorName[] contains the names of 25 competitors in a
tournament that includes five events.
Another two-dimensional (2D) array CompetitorScore[] contains the points scored by each
competitor in the five events. The first dimension of this array contains the index of the competitor
from CompetitorName[] and the second dimension contains their scores.
Each competitor receives a score out of 100 for each event. These scores are manually entered
into CompetitorScore[]
Medals are awarded to the competitor or the competitors who have:
•
•
the highest points scored in each of the five events
the highest total points scored for all five events.
The one-dimensional (1D) array Points[] stores the total number of points scored for each
competitor.
Write a program that meets the following requirements:
•
•
•
•
•
takes as input, valid scores (between 0 and 100), for each competitor in each of the five
events
calculates the highest points scored for each event
outputs the names of the competitors who receive a medal for the highest points scored
calculates the highest total points scored for the five events
outputs the names of the competitors with the highest total points scored for the five events.
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays or variables.
All inputs and outputs must contain suitable messages.
DO NOT WRITE IN THIS MARGIN
11
,
DO NOT WRITE IN THIS MARGIN
12
,
DO NOT WRITE IN THIS MARGIN
* 0000800000012 *
DO NOT WRITE IN THIS MARGIN
© UCLES 2025
ĬÑĊ®Ġ´íÈõÏĪÅĊàù¸Ā×
ĬĢæüÑĠĊĊàĉĆĆĢÐèăĥĂ
ĥĥĕÕµµÅµõõÕÅŵåÕÕÕ
2210/21/M/J/25
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000013 *
13
,
,
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
© UCLES 2025
ĬÓĊ®Ġ´íÈõÏĪÅĊàû¸Ā×
ĬĢåûÙĪĆúÙïûöèôăĕĂ
ĥĥĥĕõÕåÕĥąąÅÅÕÅĕÅÕ
2210/21/M/J/25
[Turn over
14
,
,
DO NOT WRITE IN THIS MARGIN
* 0000800000014 *
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
[15]
© UCLES 2025
ĬÍĊ®Ġ´íÈõÏĪÅĊßüµĂ×
ĬĢæùÜĨùĂëùðĠĚíø³čĂ
ĥÅĥÕµµĥõąĕąąąĕĥÕĕÕ
2210/21/M/J/25
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
* 0000800000015 *
,
© UCLES 2025
,
15
BLANK PAGE
ĬÏĊ®Ġ´íÈõÏĪÅĊßúµĂ×
ĬĢåúÔĢõòÎÿāé¾ąä³ĝĂ
ĥÅĕĕõÕąĕĕĥÕąąõąĕąÕ
2210/21/M/J/25
16
,
,
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.
© UCLES 2025
ĬÍĊ®Ġ´íÈõÏĪÅĊÝüµĄ×
ĬĢåûÔĬć÷éāĊâĠéĂãĕĂ
ĥõÅĕµÕąµõÅåąÅõåĕĕÕ
2210/21/M/J/25
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
BLANK PAGE
DO NOT WRITE IN THIS MARGIN
* 0000800000016 *