Skip to main content
EnglandComputer ScienceSyllabus dot point

What are the arithmetic, comparison and Boolean operators, and what do MOD and DIV do?

The common operators: arithmetic (add, subtract, multiply, divide, exponent, MOD and DIV), comparison operators, and Boolean operators (AND, OR, NOT), and how they are used in expressions.

An OCR J277 2.2.2 answer on the common operators: arithmetic (including exponent, MOD and DIV), comparison operators, and the Boolean operators AND, OR and NOT, with worked examples of integer division and modulus.

Generated by Claude Opus 4.810 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. Arithmetic operators
  3. Comparison operators
  4. Boolean operators
  5. Try this

What this dot point is asking

OCR wants you to use the common operators in expressions: arithmetic (add, subtract, multiply, divide, exponent, MOD and DIV), comparison operators (equal to, not equal to, less than and so on), and the Boolean operators (AND, OR, NOT). The pair that is examined most is MOD and DIV, so you must be confident with integer division and remainder. This is examined throughout Paper 2.

Arithmetic operators

MOD and DIV are powerful. number MOD 2 == 0 tests whether a number is even (remainder 0). MOD and DIV convert seconds to minutes and seconds: mins = total DIV 60 and secs = total MOD 60.

Comparison operators

Boolean operators

Try this

Q1. State the result of 23 DIV 423 \text{ DIV } 4 and 23 MOD 423 \text{ MOD } 4. [2 marks]

  • Cue. 23 DIV 4=523 \text{ DIV } 4 = 5 and 23 MOD 4=323 \text{ MOD } 4 = 3 (since 5×4=205 \times 4 = 20, remainder 3).

Q2. Write a Boolean expression that is true when a number n is even. [1 mark]

  • Cue. n MOD 2 == 0.

Q3. State what the Boolean operator OR does. [1 mark]

  • Cue. It gives true when at least one of the conditions it joins is true.

Exam-style practice questions

Practice questions written in the style of OCR exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

OCR 20213 marksState the result of each of the following expressions: (a) 17 DIV 5, (b) 17 MOD 5, (c) 2 ^ 4.
Show worked answer →

(a) 17 DIV 5=317 \text{ DIV } 5 = 3. DIV is integer (whole-number) division: it gives how many whole times 5 goes into 17, which is 3, discarding the remainder.

(b) 17 MOD 5=217 \text{ MOD } 5 = 2. MOD gives the remainder after that division: 17(3×5)=217 - (3 \times 5) = 2.

(c) 2 ^4=162 \text{ \textasciicircum } 4 = 16. The exponent operator raises 2 to the power 4, that is 2×2×2×2=162 \times 2 \times 2 \times 2 = 16.

Markers reward the three correct values. The most common error is swapping DIV and MOD: DIV gives the whole-number quotient, MOD gives the remainder.

OCR 20224 marksA program checks whether a user can enter a club: they must be aged 18 or over AND be a member. Write the condition for an if statement, and explain what the Boolean operators AND, OR and NOT do.
Show worked answer →

Condition (1 mark): if age >= 18 AND member == true then. Both parts must be true for entry, so AND is correct.

The operators (up to 3, one each): AND is true only when both conditions are true. OR is true when at least one condition is true. NOT reverses a condition, so NOT true is false and NOT false is true.

Markers reward a correct condition using AND, and a precise meaning for each operator. Saying AND means "and also" without the "both must be true" idea is not enough for the mark.

Related dot points

Sources & how we know this