Programming – O Level Computer Science (2210)

10 questions

0 / 0Answer a question to start your score.
New quizSaved 0

Quick quiz: 10 random questions from this topic. Answer them all, then open the Summary.

Advertisement
1
2210/22/O/N/24 · Question 10Oct/Nov 2024Paper 226 marks
Loading question…
Question text

10 The function LENGTH(X) calculates the length of a string X
Write the pseudocode statements to:
•
allow a line of text to be input to an appropriate variable
•
store this line of text in a text file called Main.txt
•
calculate the length of the line of text and output the text in lower case along with its length
•
store the lower-case line of text in a text file called Lowercase.txt
Make sure that any variables used are declared and that both text files are closed after they have
been used.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
ĬÓĊ®Ġ´íÈõÏĪÅĊßû¶Ā×

2
2210/21/M/J/21 · Question 1May/June 2021Paper 2120 marks
Loading question…
Question text

1
(a) All variables, constants and other identifiers must have meaningful names.
(i)
Identify one constant you could have used for Task 1, give the value that would be
assigned to it and its use.
Constant …
Value …
Use …
…
…
[3]
(ii)
Identify one variable and one array you could have used for Task 1.
Explain the use of each one.
Variable …
Use …
…
…
Array …
Use …
…
…
[4]
(b) Explain how you should change your program in Task 1 to allow a tutor to enter up to eight
candidates for the election.
…
…
…
…
…
…
…
… [4]
(c) Write an algorithm using pseudocode, programming statements or a flowchart to show how
your program completes these parts of Task 2:
•
Allows students to enter their unique voter number before casting their vote.
•
Checks whether the student has already voted:
– if so, supplies a suitable message and does not allow them to vote.
– if not, stores the unique voter number, but not their vote, in a suitable data structure.
It is not necessary to show parts completed in Task 1, including counting of votes for each
candidate.
…

3
2210/22/O/N/23 · Question 4Oct/Nov 2023Paper 229 marks
Loading question…
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.
…
…
…
…
…
…
…
…
…
…

Advertisement
4
2210/23/O/N/20 · Question 3Oct/Nov 2020Paper 234 marks
Loading question…
Question text

3
Four programming concepts and five descriptions are shown.
Draw a line to connect each Programming concept to its correct Description. Not all Descriptions
will be connected to a Programming concept.
Programming concept
Description
A subroutine that does not have to
Validation
return a value
An automatic check to ensure that data
input is reasonable and sensible
Verification
A subroutine that always returns
a value
Procedure
An overview of a program or subroutine
A check to ensure that data input
Function
matches the original
[4]
Question 4 starts on Page 12.

5
2210/21/M/J/19 · Question 4May/June 2019Paper 2111 marks
Loading question…
Question text

4
This section of program code may be used as a validation check.
1
PRINT "Input a value between 0 and 100 inclusive"
2
INPUT Value
3
WHILE Value < 0 OR Value > 100
4
PRINT "Invalid value, try again"
5
INPUT Value
6
ENDWHILE
7
PRINT "Accepted: ", Value
(a) Give a name for this type of validation check.
… [1]
(b) Describe what is happening in this validation check.
…
…
…
…
…
…
…
… [2]
(c) Complete the trace table for this program code using the test data: 200, 300, –1, 50, 60
Value
OUTPUT
[3]
(d) Draw a flowchart to represent this section of program code.
[5]

6
2210/22/O/N/18 · Question 3Oct/Nov 2018Paper 223 marks
Loading question…
Question text

3
Four programming concepts and four descriptions are shown.
Draw a line to connect each programming concept to the most appropriate description.
Programming concept
Description
A subroutine that does not
Library routine
have to return a value.
Structure
A standard subroutine that is
diagram
available for immediate use.
A subroutine that always
Procedure
returns a value.
An overview of a program or
Function
subroutine.
[3]

7
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
,
,
…
…
…

8
2210/22/M/J/25 · Question 2May/June 2025Paper 223 marks
Loading question…
Question text

2
A fence measuring 2 metres in height and 20 metres in length needs painting. The area of the
fence needs to be calculated so that enough paint for the job is purchased.
After the task is decomposed, there are three component parts: input, process and output.
Three component parts and four example descriptions are shown.
Draw one line from each component part to the most appropriate relevant description.
Not all descriptions will be used.
Component part
Description
the height of the fence
the length of the fence
process
The amount of paint required is
40 square metres.
output
the colour of the paint
input
The area of fence is calculated as
40 square metres.
[3]

Advertisement
9
2210/21/M/J/21 · Question 4May/June 2021Paper 219 marks
Loading question…
Question text

4
The pseudocode algorithm shown has been written by a teacher to enter marks for the students in
her class and then to apply some simple processing.
←
0
Count
REPEAT
INPUT Score[Count]
IF Score[Count] >= 70
THEN
←
"A"
Grade[Count]
ELSE
IF Score[Count] >= 60
THEN
←
"B"
Grade[Count]
ELSE
IF Score[Count] >= 50
THEN
←
"C"
Grade[Count]
ELSE
IF Score[Count] >= 40
THEN
←
"D"
Grade[Count]
ELSE
IF Score[Count] >= 30
THEN
←
"E"
Grade[Count]
ELSE
←
"F"
Grade[Count]
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
←
Count + 1
Count
UNTIL Count = 30
(a) Describe what happens in this algorithm.
…
…
…
…
…
…
…
… [3]
(b) Write the pseudocode to output the contents of the arrays Score[] and Grade[] along with
suitable messages.
…
…
…
…
…
…
…
…
…
…
…
… [3]
(c) Describe how you could change the algorithm to allow teachers to use it with any size of
class.
…
…

10
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]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¶Ā×

Advertisement