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.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
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. , because 5 divides into 17 three whole times.
- Modulus (MOD) returns the remainder. , because .
- Exponentiation raises to a power: and .
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, minutes and 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 but . 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 . [1 mark]
- Cue. 3, because .
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 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) , because integer division gives the whole-number quotient (5 goes into 17 three whole times) and discards any remainder.
(b) , because the remainder after dividing 17 by 5 is 2 (, and ).
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
- Follow and write algorithms (flowcharts, pseudocode, program code) that use sequence, selection, repetition (count-controlled, condition-controlled) and iteration with input, processing and output, and that use variables, constants and one- and two-dimensional data structures (strings, records, arrays).
A focused answer to Edexcel GCSE Computer Science 1.2.1 and 1.2.2, covering writing and following algorithms with sequence, selection and repetition, input-process-output, and variables, constants, strings, records and arrays.
- Determine the correct output of an algorithm for a given set of data, and use a trace table to determine what value a variable will hold at a given point in an algorithm.
A focused answer to Edexcel GCSE Computer Science 1.2.4, covering how to dry-run an algorithm, build a trace table row by row, and determine the value a variable holds and the output for given input data.
- Apply logical operators (AND, OR, NOT) in truth tables with up to three inputs to solve problems.
A focused answer to Edexcel GCSE Computer Science 1.3.1, covering the AND, OR and NOT logical operators, how to build a truth table with up to three inputs, and how to use truth tables to solve problems.
- Add together two positive binary patterns, apply logical and arithmetic binary shifts, and understand the concept of overflow in relation to the number of bits available to store a value.
A focused answer to Edexcel GCSE Computer Science 2.1.4 and 2.1.5, covering binary addition of two positive patterns, logical and arithmetic binary shifts, and the concept of overflow when a result needs more bits than are available.
- Write programs that make appropriate use of primitive data types (integer, real, Boolean, char) and one- and two-dimensional structured data types (string, array, record), and that make appropriate use of variables and constants.
A focused answer to Edexcel GCSE Computer Science 6.3.1 and 6.3.2, covering the primitive data types (integer, real, Boolean, char), structured types (string, array, record) in one and two dimensions, and using variables and constants.
Sources & how we know this
- Pearson Edexcel GCSE (9-1) Computer Science (1CP2) specification — Pearson (2020)