Level:
Correct: 0
Incorrect: 0
Marks: 0/0
Exam Practice
Subject:
Topics:
Avg
score:
–
Topics
done:
0/32

Arithmetic, relational and logical operators

Practise 30 exam-style questions on Arithmetic, relational and logical operators for Cambridge IGCSE Computer Science (Paper 2). Write your answer as you would in the exam and get it marked in seconds against the mark scheme, point by point, with an AI tutor on hand if you get stuck.

  • 30 questions
  • 1–6 marks each
  • Instant marking
  • No sign-up needed
20 questions, marked as you go

Sample questions with model answers

Here are 4 of the questions in this topic, each with a model answer, an explanation of why it earns the marks and the mark scheme an examiner would use.

Question 1

1 mark

Identify the arithmetic operator that gives the remainder when one whole number is divided by another.

Model answer

MOD, e.g. MOD(17, 5) = 2

Explanation

MOD returns the remainder after integer division, while DIV returns the whole number of times one number goes into the other. MOD is often used to test whether a number divides exactly, because the remainder is then 0.

Mark scheme
  1. 1 mark

    MOD

    Accept modulus / modulo. Do not accept DIV or /.

Question 2

2 marks

This pseudocode should output "Teenager" only for ages 13 to 19:

INPUT Age
IF Age > 12 OR Age < 20
  THEN
    OUTPUT "Teenager"
ENDIF

Explain why it outputs "Teenager" for every age, and write the corrected condition.

Model answer

OR is TRUE if either comparison is TRUE. Any age above 12 passes the first test and any age below 20 passes the second, so every possible age passes. The condition should be: Age > 12 AND Age < 20

Explanation

For a value to be inside a range, it must pass both tests, so AND is needed. OR is used for values outside a range, e.g. Age < 13 OR Age > 19 is TRUE for anyone who is not a teenager.

Mark scheme
  1. 1 mark

    With OR only one comparison needs to be TRUE, and every age is either greater than 12 or less than 20 (or both), so the condition is always TRUE

  2. 1 mark

    Age > 12 AND Age < 20

    Accept Age >= 13 AND Age <= 19.

Question 3

3 marks

Write pseudocode to input two whole numbers, First and Second. Output "Factor" if Second divides exactly into First, otherwise output "Not a factor". If Second is 0, output "Cannot divide by zero" instead.

Model answer

INPUT First
INPUT Second
IF Second = 0
  THEN
    OUTPUT "Cannot divide by zero"
  ELSE
    IF MOD(First, Second) = 0
      THEN
        OUTPUT "Factor"
      ELSE
        OUTPUT "Not a factor"
    ENDIF
ENDIF

Explanation

A number is a factor when the remainder is 0, which MOD tests. Dividing by zero causes a run-time error, so the zero check must come before MOD is used, not after it.

Mark scheme
  1. 1 mark

    MP1 inputs both numbers and checks Second = 0 first, outputting "Cannot divide by zero"

  2. 1 mark

    MP2 uses MOD(First, Second) = 0 to test whether Second is a factor

  3. 1 mark

    MP3 outputs "Factor" or "Not a factor" correctly, only when Second is not 0

Question 4

5 marks

Write pseudocode that:
- inputs a whole number, repeating the input until the number is from 100 to 999 inclusive
- uses DIV and MOD to find the three digits of the number
- outputs the sum of the three digits.

For example, 472 outputs 13.

Model answer

REPEAT
    INPUT Number
UNTIL Number >= 100 AND Number <= 999
Hundreds ← DIV(Number, 100)
Tens ← MOD(DIV(Number, 10), 10)
Units ← MOD(Number, 10)
OUTPUT "Sum of digits: ", Hundreds + Tens + Units

Explanation

The validation loop uses relational operators joined by AND to accept only three-digit numbers. DIV by a power of 10 removes digits from the right and MOD by 10 keeps only the last digit, so together they isolate each digit: for 472, 4 + 7 + 2 = 13.

Mark scheme
  1. 1 mark

    MP1 loop that repeats the input (input inside the loop)

    max 5

  2. 1 mark

    MP2 correct validation condition: Number >= 100 AND Number <= 999

    For a WHILE loop: Number < 100 OR Number > 999.

  3. 1 mark

    MP3 hundreds digit found with DIV(Number, 100)

  4. 1 mark

    MP4 tens digit found with MOD(DIV(Number, 10), 10)

    Accept DIV(MOD(Number, 100), 10).

  5. 1 mark

    MP5 units digit found with MOD(Number, 10)

  6. 1 mark

    MP6 outputs the sum of the three digits

Ready to try the rest? Every answer you write is marked against the mark scheme, so you can see exactly where the marks are.

AI Tutor Hints first, answers after you try

Hi! Stuck? Ask me for a hint and I’ll help you work it out. Once you’ve checked your answer I can explain exactly where the marks are.