Skip to main content
EnglandComputer ScienceSyllabus dot point

Which arithmetic, relational and logical operators do algorithms use, and what does each one do?

Follow and write algorithms that use arithmetic operators (addition, subtraction, division, multiplication, modulus, integer division, exponentiation), relational operators (equal to, less than, greater than, not equal to, less than or equal to, greater than or equal to) and logical operators (AND, OR, NOT).

A focused answer to Edexcel GCSE Computer Science 1.2.3, covering the arithmetic operators including modulus and integer division, the relational operators, and the logical operators AND, OR and NOT in algorithms.

Generated by Claude Opus 4.88 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. Relational operators
  4. Logical operators
  5. Operator precedence
  6. Try this

What this dot point is asking

Edexcel wants you to use the three families of operators in algorithms: arithmetic operators (including the two that GCSE students most often forget, modulus and integer division), relational operators that compare two values, and the logical operators AND, OR and NOT.

Arithmetic operators

The four basic operations are familiar, but Edexcel specifically lists integer division, modulus and exponentiation, and these are the ones questions probe.

  • Integer division (DIV) returns only the whole-number quotient. 17 DIV 5=317 \text{ DIV } 5 = 3, because 5 divides into 17 three whole times.
  • Modulus (MOD) returns the remainder. 17 MOD 5=217 \text{ MOD } 5 = 2, because 17(3×5)=217 - (3 \times 5) = 2.
  • Exponentiation raises to a power: 32=93^2 = 9 and 25=322^5 = 32.

These two are extremely useful. MOD 2 tests whether a number is even (remainder 0) or odd (remainder 1). Together, DIV and MOD split a number into parts: to convert 197 seconds into minutes and seconds, 197 DIV 60=3197 \text{ DIV } 60 = 3 minutes and 197 MOD 60=17197 \text{ MOD } 60 = 17 seconds.

Relational operators

Relational operators are what conditions in selection and repetition are built from. if mark >= 40 then uses "greater than or equal to"; while guess != target uses "not equal to". A frequent mistake is to confuse assignment with the equality test: many languages use = (or <-) to assign a value and == to test equality, so read the context carefully. At GCSE the result of a relational operator is always a Boolean, which is then used by a selection or a loop.

Logical operators

Logical operators let a single condition test several things at once. if age >= 13 AND age <= 19 then is true only for teenagers, because both comparisons must hold. if day = "Saturday" OR day = "Sunday" then is true at the weekend, because only one needs to hold. if NOT logged_in then runs when the user is not logged in. Combining operators correctly, and getting AND versus OR right, is regularly tested and links directly to truth tables.

Operator precedence

When an expression mixes operators, they are applied in a set order, just as in maths. Exponentiation is done first, then multiplication, division, integer division and modulus, then addition and subtraction, and finally the relational and logical operators. Brackets override this order, so 2+3×4=142 + 3 \times 4 = 14 but (2+3)×4=20(2 + 3) \times 4 = 20. When in doubt in an algorithm, add brackets to make the intended order explicit; this also makes the code easier to read.

Try this

Q1. State the result of 23 MOD 423 \text{ MOD } 4. [1 mark]

  • Cue. 3, because 23(5×4)=323 - (5 \times 4) = 3.

Q2. Write a condition that is true only when a number n is greater than 0 and even. [2 marks]

  • Cue. n > 0 AND n MOD 2 = 0.

Exam-style practice questions

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

Edexcel 20233 marksA program uses the expression total MOD 2. Explain what the MOD (modulus) operator calculates and how this expression could be used to test whether a number is even.
Show worked answer →

Modulus returns the remainder after an integer division. So total MOD 2\text{total MOD } 2 gives the remainder when total is divided by 2.

That remainder is 0 when total is exactly divisible by 2 (an even number) and 1 when it is not (an odd number). So the test if total MOD 2 = 0 then is true for even numbers.

Markers reward defining MOD as the remainder after division, and explaining that a remainder of 0 means even (and 1 means odd), with a correct condition.

Edexcel 20222 marksState the result of each of the following expressions: (a) 17 DIV 5 and (b) 17 MOD 5.
Show worked answer →

(a) 17 DIV 5=317 \text{ DIV } 5 = 3, because integer division gives the whole-number quotient (5 goes into 17 three whole times) and discards any remainder.

(b) 17 MOD 5=217 \text{ MOD } 5 = 2, because the remainder after dividing 17 by 5 is 2 (3×5=153 \times 5 = 15, and 1715=217 - 15 = 2).

Markers award one mark for each correct value. A common error is to swap the two, so be clear that DIV gives the quotient and MOD gives the remainder.

Related dot points

Sources & how we know this