Programming – O Level Computer Science (2210)

174 questions · page 2 of 12

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
16
2210/22/M/J/26 · Question 10May/June 2026Paper 2215 marks
Loading question…
Question text

10 A program is required to record and analyse the daily rainfall in millimetres for one year. Assume
a year has 365 days.
The one-dimensional (1D) array Rainfall[] is used to store the daily rainfall measurements.
Write a program for the following requirements:
•
Initialise the array Rainfall[] to zero.
•
Input the rainfall measurement in millimetres for each day and store it in the array.
•
Calculate the following statistics after all the inputs have been made for the year:
◦
the total rainfall for the year in centimetres (1 centimetre = 10 millimetres), rounded to
two decimal places
◦
the mean average daily rainfall in millimetres, rounded to four decimal places
◦
the total number of days with no rainfall
◦
the longest number of consecutive days in which there was no rainfall.
•
Output all the calculated statistics with clear and appropriate messaging.
•
If the longest number of consecutive days in which there was no rainfall is 15 or more,
output a message to indicate there was a drought (a long period when there is little or
no rainfall).
You must use pseudocode or program code and add comments to explain how your code works.
All arrays, variables or constants used must be declared for this algorithm.
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
© Cambridge University Press & Assessment 2026
,
,
…
…
…

17
2210/22/O/N/25 · Question 1Oct/Nov 2025Paper 221 marks
Loading question…
Question text

1
Tick (✓) one box to complete this sentence.
The result of the arithmetic operation 4 ^ 2 is
A
2
B
8
C
16
D
42
[1]

18
2210/22/O/N/25 · Question 2Oct/Nov 2025Paper 2215 marks
Loading question…
Question text

2
This pseudocode algorithm is intended to input a first name from a user and search for it in a
two‑dimensional (2D) array. If the name is found, the algorithm outputs all the remaining details for
that name. The algorithm will continue to allow other names to be entered for searching, until the
user input stops it.
01
DECLARE Contacts : ARRAY[1:500, 1:4] OF REAL
02
DECLARE Row : INTEGER
03
DECLARE Column : INTEGER
04
DECLARE Continue : BOOLEAN
05
DECLARE Stop : BOOLEAN
06
DECLARE FirstName : STRING
07
Continue
TRUE
08
Stop
FALSE
09
WHILE Continue
10
Row
1
11
OUTPUT "Enter a first name "
12
OUTPUT FirstName
13
REPEAT
14
IF Contacts[Row, 1] = FirstName
15
THEN
16
FOR Column
1 TO 4
17
OUTPUT Contacts[Row, 1]
18
NEXT Column
19
Stop
TRUE
20
ELSE
21
Row
Row + 1
22
ENDIF
23
NEXT Stop OR Row > 500
24
OUTPUT "Search for another name? (Y or N)"
25
INPUT Answer
26
IF Answer = 'N' OR Answer = 'n'
27
THEN
28
Continue
TRUE
29
ENDIF
30
ENDWHILE
(a) Identify the line numbers of five 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 …
…
Error 5 line number …
Correction …
…
[5]
(b) A procedure NewData allows data for new contacts to be entered and stored in the 2D array
Contacts[]. A parameter, Number, is used to pass values from the main algorithm to the
procedure for the number of new contacts. Next, four pieces of contact data for each new
contact are entered and stored at the start of the array.
(i)
Complete the pseudocode for PROCEDURE NewData
PROCEDURE NewData( … )
1 TO …
FOR Row
1 TO 4
FOR Column
INPUT …
…
…
ENDPROCEDURE
[4]
(ii)
Write the pseudocode to input the number of new contacts and to use procedure
NewData. A variable declaration is not required.
…

Advertisement
19
2210/22/O/N/25 · Question 3Oct/Nov 2025Paper 226 marks
Loading question…
Question text

3
A program is written that will only accept values between –99.99 and +99.99, inclusive.
The program is to be tested.
The table, when completed, shows appropriate test data that matches the type of test data and
purpose of the test data.
Complete the table by inserting the missing information.
Test data
Type of test data
Purpose of test data
…
0
…
…
boundary
…
to make sure that the program rejects data that is
outside acceptable limits
[6]
ĬÍĊ®Ġ´íÈõÏĪÅĊàü¸Ā×

20
2210/22/O/N/25 · Question 4Oct/Nov 2025Paper 227 marks
Loading question…
Question text

4
(a) A length check is a type of validation check.
State the purpose of a length check.
…
… [1]
(b) An email address can be validated by checking that it contains an @ symbol.
Write the pseudocode for an algorithm that will allow an email address to be input and check
whether or not it contains an @ symbol.
Output a suitable message with the result.
Use the string function SUBSTRING(EmailAddress, Start, 1) in your solution to return a
string of length 1 character, starting at position Start, where EmailAddress is the identifier
representing your input.
You do not need to declare any variables for this algorithm, but variables must be initialised
as necessary. Assume there will not be more than one @ symbol in the email address input.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
ĬÏĊ®Ġ´íÈõÏĪÅĊàú¸Ā×

21
2210/22/O/N/25 · Question 5Oct/Nov 2025Paper 2234 marks
Loading question…
Question text

5
This flowchart represents an algorithm.
START
INPUT Code
OUTPUT "Length
must be 4"
IS
No
LENGTH(Code)
= 4 ?
Yes
Store
FALSE
No
OUTPUT "Code
Count
1
used before"
Yes
IS Store =
FALSE ?
IS
Yes
CodeStore[Count]
= Code ?
No
IS
No
Yes
CodeStore[Count]
= "" ?
Store
TRUE
CodeStore[Count]
Code
Count
Count + 1
No
Yes
IS Count > 6
?
OUTPUT
"CodeStore
full"
STOP
ĬÑĊ®Ġ´íÈõÏĪÅĊÝúµþ×
,
,
(a) The first data row of the trace table shows the values currently stored in CodeStore[]
Complete the trace table for the algorithm, using the input data:
7686, Face, Speed, 432U, Yp79
CodeStore[]
Code
Store
Count
[1]
[2]
[3]
[4]
[5]
[6]
OUTPUT
aBcd
1532
Face
63q8
[6]
ĬÓĊ®Ġ´íÈõÏĪÅĊÝüµþ×
,
,
(b) Describe the processes in the algorithm on page 6.
…
…
…
…
…
… [3]
(c) The algorithm on page 6 requires the array CodeStore[] to be declared as a
one‑dimensional (1D) string array with six elements that are initially set to the null string "".
Write the pseudocode required to declare and initialise the array CodeStore[]
You do need to declare any variables used.
…
…
…
…
…
…
…
… [4]
ĬÑĊ®Ġ´íÈõÏĪÅĊßúµĀ×

22
2210/22/O/N/25 · Question 8Oct/Nov 2025Paper 2215 marks
Loading question…
Question text

8
A program is required to test the fairness of the random number generator.
The one‑dimensional (1D) array RandomNumber[] is used to store 100 000 random integers.
The two‑dimensional (2D) array CountedNumber[] is used to store the integers 1 to 10, inclusive,
and the frequency of each integer (the number of times each integer was generated).
Write a program that meets the following requirements:
•
Generate 100 000 random integers between 1 and 10, inclusive.
•
Store each integer in the appropriate array.
•
Calculate the frequency of each of the integers 1 to 10 and store these values in the
appropriate array.
•
Sort the contents of the counted number array in descending order of frequency.
•
Calculate the chance of generating each of the integers 1 to 10, rounded to four decimal
places.
Use the formula: chance = frequency / 100000
•
Output each of the integers 1 to 10 in the order they are stored in the counted number array,
along with the chance of generating them.
The following is an example of an algorithm that sorts a 2D array in an ascending order:
TRUE
F
WHILE F DO
F
FALSE
FOR I
1 TO 9
IF A[I, 2] > A[I +
1, 2]
THEN
T1
A[I, 1]
T2
A[I, 2]
A[I, 1]
A[I
+ 1, 1]
A[I, 2]
A[I
+ 1, 2]
A[I + 1, 1]
T1
A[I + 1, 2]
T2
F
TRUE
ENDIF
NEXT I
ENDWHILE
You must use pseudocode or program code and add comments to explain how your code works.
All arrays, variables or constants used must be declared for this algorithm.
All inputs and outputs must contain suitable messages.
…
…
…
…
…
…
ĬÑĊ®Ġ´íÈõÏĪÅĊàú·Ā×
,
,
…
…
…
…
…
…
…
…
…
…
..

23
2210/23/O/N/25 · Question 1Oct/Nov 2025Paper 233 marks
Loading question…
Question text

1
Give three ways of creating a maintainable program.
1 …
2 …
3 …
[3]

Advertisement
24
2210/23/O/N/25 · Question 2Oct/Nov 2025Paper 234 marks
Loading question…
Question text

2
Four descriptions of programming techniques and five programming techniques are given.
Draw one line from each description to the relevant technique. Not all techniques will be used.
Description
Programming technique
output
adding up a set of numbers
selection
displaying the result of a
calculation
totalling
executing a set of instructions
based on a condition
iteration
executing the same set of
counting
instructions multiple times
[4]

25
2210/23/O/N/25 · Question 3Oct/Nov 2025Paper 231 marks
Loading question…
Question text

3
Tick (3) one box to identify the most appropriate data type to store 'M'
A
integer
B
char
C
real
D
Boolean
[1]
ĬÍĊ®Ġ´íÈõÏĪÅĊßû·þ×

26
2210/23/O/N/25 · Question 5Oct/Nov 2025Paper 236 marks
Loading question…
Question text

5
A program has been written in pseudocode to input five numbers between 1 and 900 inclusive and
store the highest number and the lowest number entered.
900
01
Lowest
1
02
Highest
1 TO 5
03
FOR Count
04
INPUT Number
05
IF Number < Lowest
06
THEN
Number
07
Lowest
08
ELSE
09
IF Number > Highest
10
THEN
Number
11
Highest
12
ENDIF
13
ENDIF
14
NEXT Count
(a) Complete the trace table for the algorithm using the following numbers:
563, 21, 376, 99, 400
Count
Number
Lowest
Highest
[4]
(b) The algorithm does not work correctly.
State the reason why the algorithm does not work as expected and explain how the algorithm
could be corrected.
Any code used must be fully explained.
Reason …
…
Correction …
…
[2]
ĬÏĊ®Ġ´íÈõÏĪÅĊÝù·Ā×

27
2210/23/O/N/25 · Question 7Oct/Nov 2025Paper 238 marks
Loading question…
Question text

7
An algorithm has been written in pseudocode to:
•
input a whole number between 1 and 255 inclusive
•
convert the input to an 8-bit binary number
•
store each bit of the binary number in an array.
For example, if the denary number 127 was input, the binary number 01111111 would be stored in
the array.
01
DECLARE BinaryArray : ARRAY[1:8] OF INTEGER
02
DECLARE DenaryNumber : CHAR
03
OUTPUT "Please enter a whole number between 1 and 255 inclusive "
04
INPUT DenaryNumber
7 TO 1 STEP -1
05
FOR Count
MOD(DenaryNumber,3)
06
BinaryArray[Count]
DIV(DenaryNumber,2)
07
DenaryNumber
08
NEXT Count
(a) Identify the line numbers of the three 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 …
…
[3]
ĬÑĊ®Ġ´íÈõÏĪÅĊÞù¶Ā×
,
,
(b) Identify one programming technique used in the algorithm.
… [1]
(c) (i)
The algorithm can accept a number between 1 and 255 inclusive as input.
Two validation checks that could be applied to DenaryNumber are a presence check
and a type check.
Identify one other validation check that could be applied to DenaryNumber
… [1]
(ii)
Write the pseudocode to implement the validation check you identified in (c)(i).
You do not need to rewrite the whole algorithm.
…
…
…
…
…
… [3]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¶Ā×

28
2210/23/O/N/25 · Question 9Oct/Nov 2025Paper 2310 marks
Loading question…
Question text

9
The variables Name, Age and Found are used in a computer program.
Name holds the name of a person. Age holds the age of a person as a whole number.
Found holds a flag that can be set to TRUE or FALSE
(a) Write pseudocode statements to declare the variables Name, Age and Found
…
…
… [3]
(b) The procedure StoreData(Name) stores the name of a person in the file People.txt
(i)
Write pseudocode statements to:
•
define the procedure with the parameter
•
store the name of the person in the file.
…
…
…
…
…
…
…
…
…
… [5]
(ii)
Write the pseudocode that uses the procedure StoreData() to store the name ‘Suella’
in the file People.txt
…
…
… [2]
ĬÓĊ®Ġ´íÈõÏĪÅĊßû¸þ×

Advertisement
29
2210/23/O/N/25 · Question 10Oct/Nov 2025Paper 2315 marks
Loading question…
Question text

10 A number game has two players. Random whole numbers are generated for each player. The
numbers are compared and players are given points based on the result of the comparison.
The two-dimensional (2D) array NumberGenerated[] stores each number generated for each
player. The first dimension stores the player number and the second dimension stores the random
whole numbers generated.
The game is played as follows:
•
100 random whole numbers between 1 and 6 inclusive are generated for player 1 and stored
in the array.
•
100 random whole numbers between 1 and 6 inclusive are generated for player 2 and stored
in the array.
•
The first number generated for each player is compared and the player with the higher number
is awarded 2 points. If the two numbers are the same, both players are awarded 1 point each.
•
The comparisons repeat for all 100 numbers generated.
•
The player with the higher total number of points is output as the winner.
•
If the players have the same total number of points, a new random whole number is generated
for each player and compared. This is repeated until one player has a higher number than the
other player. 2 points are added to that player’s total number of points, making this player the
winner.
Write a program that meets the following requirements:
•
input and validate the names of the two players
•
generate 100 random whole numbers between 1 and 6 inclusive for each player and store
them in the array NumberGenerated[]
•
calculate and store the total number of points for each player
•
output the name and total number of points for each player in descending order of total
number of points.
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; assume that this has already been done.
All outputs must contain suitable messages.
…
…
…
…
…
…
…
…
…
…
ĬÑĊ®Ġ´íÈõÏĪÅĊÝù¸Ā×
,
,
…
…
…
…

30
2210/21/M/J/25 · Question 3May/June 2025Paper 214 marks
Loading question…
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]
ĬÏĊ®Ġ´íÈõÏĪÅĊÞù·þ×

Advertisement