Identify four operators that are not arithmetic operators from the list: / > <= + * ^ AND DIV MOD NOT. [4]
Show model answer
> ; <= ; AND ; NOT (in any order).
Comparison (>, <=) and logical (AND, NOT) operators are not arithmetic.
Practise 39 real questions on Programming from 2021 to 2026. See the answer and explanation as soon as you answer.
Programming is one of the 4 main topics in our O Level Computer Science (Cambridge (CAIE) 2210) question bank, and about 20% of its real questions come from it. Tayyari Karo has 39 real questions on this topic from 2021 to 2026, from Paper 1, Paper 2. By difficulty: 20 easy, 12 medium, 7 hard.
Work through the questions below, then open the explanation for each one. Redo the ones you missed a few days later.
These are real past-paper questions. Think of your answer first, then open the explanation.
Identify four operators that are not arithmetic operators from the list: / > <= + * ^ AND DIV MOD NOT. [4]
> ; <= ; AND ; NOT (in any order).
Comparison (>, <=) and logical (AND, NOT) operators are not arithmetic.
The function Power(FirstNumber, SecondNumber) returns the value of FirstNumber raised to the power of SecondNumber. FirstNumber and SecondNumber are integers. Write pseudocode statements to: define the function; call the function with the variables A and B and store the return value in the variable Value. [5]
Function definition:
FUNCTION Power(FirstNumber : INTEGER, SecondNumber : INTEGER) RETURNS INTEGER
RETURN FirstNumber ^ SecondNumber
ENDFUNCTION
Function call:
Value <- Power(A, B)
(Alternative calculation using a loop: Num <- 1; FOR I <- 1 TO SecondNumber; Num <- Num * FirstNumber; NEXT I; RETURN Num.)
Marks are for the FUNCTION ... RETURNS ... ENDFUNCTION structure, the parameters, the calculation, the RETURN, and the call.
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.
MOD returns the remainder of integer division, e.g. R <- 9 MOD 4 (R = 1).
DIV returns the integer quotient (whole-number part) of integer division, e.g. Q <- 9 DIV 4 (Q = 2).
MOD = remainder; DIV = integer quotient.
10 Variables Seconds and Minutes are whole numbers.
(a) Write pseudocode to declare Seconds and Minutes.
(b) The procedure Time(TotalSeconds) takes seconds as a parameter and converts it into minutes and seconds, outputting the result. Write this procedure in pseudocode.
10 (a) DECLARE Seconds : INTEGER; DECLARE Minutes : INTEGER.
(b) PROCEDURE Time(TotalSeconds)
Minutes <- TotalSeconds DIV 60
Seconds <- TotalSeconds MOD 60
OUTPUT Minutes, " minutes and ", Seconds, " seconds"
ENDPROCEDURE
(a) Outline why it is useful to store data in a file. (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.
(a) Storing data in a file makes it persistent (kept after the program ends), allows it to be retrieved later, shared between programs/users, and stored on secondary storage.
(b) OPEN "Quotation.txt" FOR INPUT AS #f
READ #f, Text
CLOSE #f
OUTPUT UPPER(Text)
OUTPUT LENGTH(Text)
Read file into string, then OUTPUT UPPER and LENGTH.
The function LENGTH(Phrase) calculates the length of a string Phrase. (a) Write the pseudocode statements to: store the string "The beginning is the most important part" in Phrase; calculate and output the length of the string; output the string in upper case. (b) Write the output your pseudocode should produce.
(a) Phrase <- "The beginning is the most important part"
OUTPUT LENGTH(Phrase)
OUTPUT UPPER(Phrase)
(b) 40
THE BEGINNING IS THE MOST IMPORTANT PART
Length = 40 characters; upper-case version as shown.
2 Tick one box to show how a value can be passed to a procedure: function, parameter, return, subroutine.
2 parameter
Section B. Tick one box in each row to identify the most appropriate data type for each description. Only one tick per column. Description / Data type (Boolean, Char, Integer, Real, String): a single character from the keyboard; multiple characters from the keyboard; only one of two possible values; only whole numbers; any number.
a single character from the keyboard -> Char.
multiple characters from the keyboard -> String.
only one of two possible values -> Boolean.
only whole numbers -> Integer.
any number -> Real.
Char=single char, String=many chars, Boolean=2 values, Integer=whole, Real=any number.
| Session | Paper 1 | Paper 2 |
|---|---|---|
| May/June 2026 | – | 6 |
| May/June 2025 | – | 5 |
| Oct/Nov 2025 | – | 3 |
| May/June 2024 | – | 4 |
| Oct/Nov 2024 | 1 | 4 |
| May/June 2023 | – | 3 |
| Oct/Nov 2023 | – | 6 |
| May/June 2022 | – | 2 |
| Oct/Nov 2022 | 1 | – |
| May/June 2021 | – | 3 |
| Oct/Nov 2021 | 1 | – |
39 real O Level Computer Science (2210) questions on Programming from 2021 to 2026, from Paper 1, Paper 2. Each one shows the year, session and paper it came from.
Yes. Every question shows the correct answer and a short explanation the moment you answer.
You can start free with no signup. A small set of papers per subject is free, and Premium unlocks every paper, the full question bank and the paper PDFs.