TopMyGrade

GCSE/Computer Science/OCR

2.2.2Operators: arithmetic (+, −, *, /, MOD, DIV, ^), comparison (=, ≠, <, ≤, >, ≥), Boolean (AND, OR, NOT)

Notes

Operators

OCR J277 Paper 2 expects you to know the symbol, name and effect of every operator on the spec. Mistakes with MOD, DIV, integer division and string comparison appear every year.

Arithmetic operators

SymbolMeaningExampleResult
+Addition7 + 310
Subtraction7 − 34
*Multiplication7 * 321
/Division (real result)7 / 23.5
MODModulus — remainder of integer division7 MOD 31
DIVInteger division — quotient discarding remainder7 DIV 32
^Exponentiation (to the power of)2 ^ 38

Common uses of MOD and DIV

  • isEven(x) — true if x MOD 2 = 0.
  • Convert seconds to minutes and seconds — minutes = totalSeconds DIV 60; seconds = totalSeconds MOD 60.
  • Last digit of an integer — n MOD 10.

Comparison (relational) operators

SymbolMeaning
=Equal to
≠ (or <>)Not equal to
<Less than
Less than or equal to
>Greater than
Greater than or equal to

Comparison operators always evaluate to a Boolean (TRUE / FALSE). They work on numbers and (in most languages) strings, where the comparison is alphabetical/lexicographic.

Boolean (logical) operators

OperatorEffect
ANDTRUE only if both operands are TRUE
ORTRUE if either operand (or both) is TRUE
NOTReverses the value (TRUE ↔ FALSE)

Order of evaluation

In an expression, the order is usually:

  1. Brackets
  2. ^ (exponent)
  3. *, /, DIV, MOD
  4. +, -
  5. Comparison
  6. NOT, AND, OR (NOT first, then AND, then OR)

Use brackets when in doubt.

Common OCR exam mistakes

  • Using / when DIV is needed (or vice-versa) — / returns a real, DIV returns an integer.
  • Saying 7 MOD 3 = 2 — it is 1 (the remainder, not the quotient).
  • Mixing up ≤ and < (boundary errors), or ≥ and >.
  • Forgetting NOT has higher precedence than AND/OR.
  • Using = for assignment in pseudocode where OCR uses ← — be careful in code-reading questions.

AI-generated · claude-opus-4-7 · v3-ocr-computer-science-leaves

Practice questions

Try each before peeking at the worked solution.

  1. Question 15 marks

    Evaluate expressions

    State the value of each expression:
    (a) 17 MOD 5 [1]
    (b) 17 DIV 5 [1]
    (c) 2 ^ 4 [1]
    (d) (5 + 3) * 2 [1]
    (e) 25 / 4 [1]

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-ocr-computer-science-leaves

  2. Question 24 marks

    Boolean expressions

    Given a = 5, b = 10 and c = 5, state TRUE or FALSE for each expression:
    (a) (a = c) AND (b > a) [1]
    (b) (a > c) OR (b < a) [1]
    (c) NOT (a = b) [1]
    (d) (a < b) AND NOT (c = a) [1]

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-ocr-computer-science-leaves

  3. Question 34 marks

    Apply MOD/DIV in pseudocode

    Write pseudocode in OCR Reference Language that takes a total number of seconds entered by the user and outputs the number of complete minutes and the remaining seconds. [4 marks]

    Ask AI about this

    AI-generated · claude-opus-4-7 · v3-ocr-computer-science-leaves

Flashcards

2.2.2 — Operators: arithmetic, comparison and Boolean

7-card SR deck for OCR Computer Science (J277) — leaves batch 1 topic 2.2.2

7 cards · spaced repetition (SM-2)