Past paper – O Level Computer Science (2210)
Cambridge O Level · 2210
Computer Science · Paper 21
May/June 2024 · 2210/21/M/J/24
Answer on paper, open each mark scheme and give yourself marks, then open the Summary.
Question text
1
Tick ( ü ) one box to complete this sentence.
A validation check to make sure that an email address contains an ‘@’ sign is a
A
range check.
B
visual check.
C
presence check.
D
format check.
[1]
Question text
2
Four descriptions of programming concepts and five programming concepts are shown.
(a) Draw one line to link each description to the most appropriate programming concept.
Not all programming concepts will be used.
Description
Programming concept
function
a subroutine that may not return a value
procedure
a value that is declared and used within a
specific procedure
parameter
a value that a procedure expects you to
supply when it is called
global variable
a subroutine that will always return a value
local variable
[4]
(b) Write the pseudocode to use a procedure named Average that passes the values 25 and 50
to the procedure.
…
… [2]
(c) Outline the role of procedures and functions in creating a program that is easier to maintain.
…
…
…
…
…
… [3]
Question text
3
State what is meant by the data types integer and real.
Give an example of each.
Integer …
…
Example …
Real …
…
Example …
[4]
Question text
4
This pseudocode algorithm is intended to allow, at random, between 1 and 20 values to be entered
and totalled. The total and average of the entered values are output at the end of the algorithm.
01
DECLARE Loop : STRING
02
DECLARE Limit : INTEGER
03
DECLARE Value : REAL
04
DECLARE Total : REAL
0
05
Total
ROUND(RANDOM() * 19,0) + 1
06
Limit
1 TO Limit
07
IF Loop
08
OUTPUT "Enter a number"
09
INPUT Loop
Total * Value
10
Total
11
NEXT Loop
12
OUTPUT "The total of the numbers entered is ", Total
13
OUTPUT "The average of the numbers entered is ", Total / Limit
(a) Identify the line numbers of four errors in the pseudocode and suggest corrections.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
[4]
(b) Write the pseudocode statement that would output the average calculated in line 13 of the
algorithm rounded to one decimal place.
…
…
…
… [2]
(c) Explain how you should alter the original corrected algorithm to make sure that all the
numbers entered are between 1 and 500 inclusive. If any numbers fall outside these limits, a
replacement value is requested and entered.
You do not need to re-write the algorithm.
…
…
…
…
…
Question text
5
Write the pseudocode statements to perform this task:
•
accept the input of a whole number from 1 to 4 inclusive
•
use a CASE statement to:
○ output the number (1 to 4 inclusive) that was entered
○ output the word “ERROR” if a 1 to 4 inclusive number was not entered.
…
…
…
…
…
…
…
…
…
… [5]
Question text
6
The flowchart represents an algorithm.
START
Result
Limit DIV 2 + 1
INPUT
Limit
OUTPUT
Numbers[Result]
Count
1
INPUT
Numbers[Count]
STOP
Count
Count + 1
No
IS Count >
Limit?
No
IS Numbers[Count] >
Yes
Numbers[Count + 1]?
Flag
TRUE
Yes
Swap
Numbers[Count]
IS Flag =
No
TRUE?
Numbers[Count]
Numbers[Count + 1]
Yes
Flag
False
Numbers[Count + 1]
Swap
Count
1
Flag
True
IS Count >
Yes
No
Limit – 1?
Count
Count + 1
(a) Complete the trace table for the input data:
7, 47, 50, 52, 60, 80, 63, 70
Numbers
Limit
Count
[1]
[2]
[3]
[4]
[5]
[6]
[7]
Flag
Swap
Result
OUTPUT
[7]
(b) Outline the processes involved in the algorithm shown in the flowchart on page 6.
…
…
…
…
…
… [3]
Question text
7
(a) Outline why it is useful to store data in a file.
…
…
…
… [2]
(b) The function LENGTH(X) calculates the length of a string X
Write the pseudocode statements to:
•
read the contents of the text file Quotation.txt into an appropriate string variable that
has been declared
•
output the string in upper case and the length of the string.
…
…
…
…
…
…
…
… [4]
Question text
8
Consider the logic expression:
Z = (R OR NOT T) XOR (NOT S AND T)
(a) Draw a logic circuit for this logic expression.
Each logic gate must have a maximum of two inputs.
Do not simplify this logic expression.
R
S
Z
T
[5]
(b) Complete the truth table from the given logic expression.
Working space
R
S
T
Z
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
A database table called SoftDrinks stores details of the soft drinks sold by a small shop.
9
Field
Example data
Name
Cola
Supplier
Cambridge Beverages
Container
Can
SizeCl
330
NumberInStock
30
ReorderLevel
15
Reordered
Yes
(a) State whether any of the given fields would be suitable as a primary key and give a reason for
your answer.
…
… [1]
(b) Complete the structured query language (SQL) statement to return the number of cans the
shop has in stock.
SELECT … ( … )
FROM …
WHERE … = … ;
[5]
Question text
10 The one-dimensional (1D) array Clubs[] is used to store the names of 12 cricket clubs in a local
sports league.
The two-dimensional (2D) array Statistics[] is used to store, for each cricket club, the number
of:
•
matches won
•
matches drawn
•
matches lost.
The 1D array Points[] is used to store the total number of points each cricket club has been
awarded.
The position of any cricket club’s data is the same in all three arrays. For example, the data in
index 2 of Statistics[] and index 2 of Points[] belongs to the cricket club in index 2 of
Clubs[]
The variable Matches stores the number of matches played by each team. Each team plays the
same number of matches.
Points are awarded for:
•
a win – 12 points
•
a draw – 5 points
•
a loss – 0 points.
Write a program that meets the following requirements:
•
allows the number of matches played to be input and stored, with a maximum of 22 matches
•
validates the number of matches played
•
allows the names of the cricket clubs to be input and stored
•
allows the number of matches won, drawn and lost to be input and stored for each team
•
validates the number of matches won, drawn or lost against the number of matches played
•
asks the user to re-enter the number of matches won, drawn or lost if the total does not match
the number of matches played
•
calculates and stores the total number of points for each club
•
finds the cricket club or clubs with the highest number of points
•
outputs the name or names of the winning club or clubs, the number of wins and the total
number of points awarded.
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; you may assume that this has already been
done.
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…