Past paper – O Level Computer Science (2210)
Cambridge O Level · 2210
Computer Science · Paper 21
May/June 2025 · 2210/21/M/J/25
Answer on paper, open each mark scheme and give yourself marks, then open the Summary.
Question text
1
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]
Question text
2
Four requirements for validating inputs and five types of validation check are given.
(a) Draw one line from each requirement to the most appropriate validation check.
Not all validation checks will be used.
Requirement
Validation check
length check
Date of birth must be between
01/01/1900 and 01/01/2010.
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 …
…
…
…
[3]
ĬÍĊ®Ġ´íÈõÏĪÅĊÞû·þ×
Question text
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]
ĬÏĊ®Ġ´íÈõÏĪÅĊÞù·þ×
Question text
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.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [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.
…
…
…
…
Question text
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 …
…
DIV purpose …
…
Example pseudocode …
…
[4]
ĬÏĊ®Ġ´íÈõÏĪÅĊàù·Ā×
Question text
6
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.
0
01
Counter
ROUND(RANDOM() * 99, 1) + 1
02
N
03
REPEAT
04
OUTPUT "Please enter a guess"
05
INPUT G
06
IF G > N
07
THEN
08
OUTPUT "The number is lower than your guess"
09
ELSE
10
IF G < N
11
THEN
12
OUTPUT "The number is lower than your guess"
13
ENDIF
Counter + 1
14
Counter
15
ENDIF
16
UNTIL G = N
17
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 …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
[4]
(b) Identify one method to make the algorithm maintainable.
Give an example.
…
…
…
… [2]
ĬÑĊ®Ġ´íÈõÏĪÅĊÝù¶þ×
Question text
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.
Do not simplify the logic expression.
A
B
X
C
[4]
(b) Complete the truth table for the given logic expression.
Working space
A
B
C
X
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
[4]
ĬÓĊ®Ġ´íÈõÏĪÅĊÝû¶þ×
Question text
8
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)
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
WHERE Driver = "A Patel";
…
…
…
…
… [2]
ĬÑĊ®Ġ´íÈõÏĪÅĊßù¶Ā×
,
,
(c) Complete the SQL statement to display only the destination of the buses that have a return.
SELECT …
…
…
… [3]
Question text
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 …
…
…
…
…
…
…
…
…
…
…
Function call …
…
[6]
ĬÓĊ®Ġ´íÈõÏĪÅĊßû¶Ā×
Question text
10 The flowchart represents an algorithm to calculate grades.
START
INPUT
Score
IS Score
Yes
Grade
"C"
>= 40 ?
No
IS Score
Yes
Grade
"B"
>= 60 ?
No
IS Score
Yes
Grade
"A"
>= 80 ?
No
Grade
"D"
OUTPUT "You
achieved a ", Grade
STOP
ĬÑĊ®Ġ´íÈõÏĪÅĊÞù¸þ×
,
,
(a) Complete the trace table for the algorithm, using the input data:
21, 46, 63, 91, 12
Score
Grade
OUTPUT
[3]
(b) Explain how the flowchart can be changed to produce the correct output.
…
…
…
…
…
…
…
… [4]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¸þ×
Question text
11
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.
…
…
…
…
…
…
…
…
…
…
…
…
ĬÑĊ®Ġ´íÈõÏĪÅĊàù¸Ā×
,
,
…
…
…
…
…