Tayyari Karo Open the app

O Level Computer Science: Programming, questions with answers

Practise 39 real questions on Programming from 2021 to 2026. See the answer and explanation as soon as you answer.

39real questions
2papers covered
11exam sessions

About Programming in O Level Computer Science

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.

Try 8 real questions

These are real past-paper questions. Think of your answer first, then open the explanation.

May/June 2026 · Paper 2 · Programming

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.

May/June 2026 · Paper 2 · Programming

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]

Show model answer

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.

May/June 2025 · Paper 2 · Programming

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.

Show model answer

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.

Oct/Nov 2025 · Paper 2 · Programming

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.

Show model answer

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

May/June 2024 · Paper 2 · Programming

(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.

Show model answer

(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.

May/June 2023 · Paper 2 · Programming

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.

Show model answer

(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.

Oct/Nov 2023 · Paper 2 · Programming

2 Tick one box to show how a value can be passed to a procedure: function, parameter, return, subroutine.

Show model answer

2 parameter

May/June 2022 · Paper 2 · Programming

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.

Show model answer

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.

Sessions with Programming questions

SessionPaper 1Paper 2
May/June 2026–6
May/June 2025–5
Oct/Nov 2025–3
May/June 2024–4
Oct/Nov 202414
May/June 2023–3
Oct/Nov 2023–6
May/June 2022–2
Oct/Nov 20221–
May/June 2021–3
Oct/Nov 20211–

Common questions

What does the Programming topic cover on this page?

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.

Do I get the answers and explanations?

Yes. Every question shows the correct answer and a short explanation the moment you answer.

Is it free?

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.

Other Computer Science topics

All O Level Computer Science questions

Computer Science at other levels

Ready to start?

Free to start. No signup needed to try the questions.

Open Tayyari Karo