Past paper – O Level Computer Science (2210)
Cambridge O Level · 2210
Computer Science · Paper 22
Oct/Nov 2023 · 2210/22/O/N/23
Answer on paper, open each mark scheme and give yourself marks, then open the Summary.
Question text
1
Tick (✓) one box to complete the sentence.
Verification is used to make sure that a value entered
A
has not changed during input.
B
is an integer.
C
is correct.
D
is not a string.
[1]
Question text
2
A type of validation check is a length check. Another type of validation check is used to make sure
that any date entered is in the dd/mm/yyyy style:
dd means day, mm means month and yyyy means year.
(a) State the type of validation check used.
… [1]
(b) Give one example of normal test data and one example of abnormal test data you should
use to make sure the check in part (a) is working properly.
State a reason for each of your choices of test data.
Normal …
Reason …
…
Abnormal …
Reason …
…
[4]
(c) Describe how a length check could be used with the date entered.
…
…
…
… [2]
Question text
3
Four pseudocode statements and five pseudocode uses are shown.
(a) Draw one line to link each pseudocode statement to the most appropriate pseudocode use.
Not all pseudocode uses will be required.
Pseudocode use
Pseudocode statement
CALL Colour(NewColour)
counting
finding an average
Value
(A1 + A2 + A3) / 3
totalling
Loop1
Loop1 + 1
using a conditional statement
IF Count > 7 THEN X1
0
using a procedure
[4]
(b) A one‑dimensional (1D) array called Temperatures[] has 25 elements beginning at
index 1. It holds values that range between –20 and 100 inclusive.
Write a pseudocode algorithm using a single loop to find the lowest value in this array and
output the result only once.
You do not need to declare or populate this array.
…
…
…
…
…
…
…
…
…
…
…
… [4]
Question text
4
An algorithm has been written in pseudocode to allow the names of 50 cities and their countries to
be entered and stored in a two‑dimensional (2D) array. The contents of the array are then output.
01
DECLARE City ARRAY[1:50, 1:2] OF BOOLEAN
02
DECLARE Count : INTEGER
03
DECLARE Out : INTEGER
1
04
Count
05
IF
06
OUTPUT "Enter the name of the city"
07
INPUT City[Count, 2]
08
OUTPUT "Enter the name of the country"
09
INPUT City[Count, 2]
Count + 1
10
Count
11
UNTIL Count = 50
1 TO 1
12
FOR Out
13
OUTPUT "The city ", City[Out, 1], " is in ", City[Out, 2]
14
NEXT Out
(a) Identify the four errors in the pseudocode and suggest corrections.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
[4]
(b) Describe the changes you should make to the corrected algorithm to allow the name of a
country to be input and to display only the stored cities from that country.
You do not need to rewrite the algorithm.
…
…
…
…
…
…
…
…
…
…
Question text
5
Explain how variables and constants should be used when creating and running a program.
…
…
…
…
…
… [3]
Question text
6
The flowchart represents an algorithm that performs a process on groups of values that are input.
The algorithm will fail if the first value of any group is 0.
An input of –1 will terminate the algorithm.
START
Total
0
OUTPUT
"Average is ",
Average
Count
0
OUTPUT
INPUT
"Total is ",
Value
Total
IS
Yes
Value =
Average
Total / Count
0 ?
No
IS
Yes
STOP
Value =
–1 ?
No
Total
Total + Value
Count
Count + 1
(a) Complete the trace table for the input data:
25, 35, 3, 0, 57, 20, 25, 18, 0, –1, 307, 40, 0
Value
Average
Total
Count
OUTPUT
[5]
(b) Describe the purpose of the algorithm.
…
…
…
… [2]
Question text
7
The string operation SUBSTRING(Quote, Start, Number) returns a string from Quote
beginning at position Start that is Number characters long. The first character in Quote is in
position 1.
Write pseudocode statements to:
•
store the string "Learning Never Exhausts The Mind" in Quote
•
extract and display the words "The Mind" from the string
•
output the original string in lower case.
…
…
…
…
…
…
…
…
…
…
…
… [5]
Question text
8
Explain why a programmer would use procedures and parameters when writing a program.
…
…
…
…
…
…
…
… [4]
Question text
9
Consider the logic expression:
Z = (A NAND B) OR NOT (B XOR C)
(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.
A
Z
B
C
[4]
(b) Complete the truth table from the given logic expression.
Working space
A
B
C
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
10 A database table called Horses stores details about the horses kept at a horse sanctuary.
Code
Breed
BreedOrigin
Gender
Age
Arrived
H002
Arabian
Saudi Arabia
M
5
28/09/2022
H004
Percheron
France
M
5
30/10/2022
H010
Friesian
Netherlands
M
6
15/11/2022
H011
Fjord
Norway
F
4
17/11/2022
H012
Clydesdale
Scotland
M
10
18/11/2022
H015
Arabian
Saudi Arabia
F
5
15/12/2022
H016
Arabian
Saudi Arabia
F
5
15/12/2022
H017
Clydesdale
Scotland
F
4
16/01/2023
H019
Percheron
France
M
3
16/01/2023
H025
Percheron
France
M
7
16/01/2023
H026
Clydesdale
Scotland
F
9
20/01/2023
H030
Clydesdale
Scotland
M
12
20/01/2023
H032
Fjord
Norway
M
3
24/03/2023
H033
Arabian
Saudi Arabia
F
15
27/04/2023
H034
Clydesdale
Scotland
F
4
14/06/2023
H035
Fjord
Norway
M
7
15/06/2023
H036
Friesian
Netherlands
F
15
20/07/2023
H037
Friesian
Netherlands
M
12
20/07/2023
(a) State the number of records in this database table.
… [1]
(b) Give the name of the field that is most suitable to be the primary key.
State the reason for this choice.
Field …
Reason …
…
[2]
(c) The database only allows the data types:
•
Boolean
•
character
•
date/time
•
integer
•
real
•
text.
Complete the table to show the most appropriate data type for each field.
Each data type must be different.
Field
Data type
Breed
Gender
Age
Arrived
[2]
(d) Complete the structured query language (SQL) to return the code and breed of all the horses
whose breed originated in Scotland.
… Code, Breed,
FROM …
WHERE … = "Scotland";
[3]
Question text
11
A wood flooring company stores the names of up to 100 customers in a one‑dimensional (1D) array
Customers[]. A two‑dimensional (2D) array Quotations[] stores details of each customer’s
quotation:
•
length of room (one decimal place)
•
width of room (one decimal place)
•
area of wood required (rounded up to next whole number)
•
choice of wood index (whole number)
•
price of wood required in dollars (two decimal places).
The floor measurements (room length and room width) are taken in metres. All floors are rectangles
and room measurements must be between 1.5 and 10.0 inclusive.
The index of any customer’s data is the same in both arrays. For example, a customer named in
index 4 of Customers[] corresponds to the data in index 4 of Quotations[]
The wood choices available are:
Index
Wood type
Price per square metre ($)
1
Laminate
29.99
2
Pine
39.99
3
Oak
54.99
The data are stored in two 1D arrays named WoodType[] and Price[]. The index of the wood
type and price in their arrays share the same index number.
Write a program that meets the following requirements:
•
input a new customer’s name, room length and room width
•
check that each measurement is valid
•
output an error message and require the measurement to be re‑entered until it is valid
•
calculate the area of the room by multiplying together the length of the room and the width of
the room
•
input the choice of wood and find its price per square metre
•
calculate the price of the wood needed
•
store all data in the relevant array
•
output the customer’s quotation to include: the name of the customer, the choice of wood and
the calculated price of the wood required
•
continue to accept the next customer.
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.
You will need to initialise WoodType[] and Price[]
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
…
…
…
…
…
…