Arithmetic and relational operators (Edexcel GCSE Computer Science): Revision Notes
Arithmetic and relational operators
Introduction to operators
When writing computer programmes and algorithms, we need special symbols called operators to help us perform calculations and make comparisons. There are two main types of operators you need to understand for your GCSE: arithmetic operators for doing maths, and relational operators for comparing values.
Arithmetic operators
Arithmetic operators are the mathematical symbols that allow us to carry out calculations within our programmes. Think of them as the basic tools for doing maths with computers.

Basic arithmetic operations
The most familiar arithmetic operators work just like they do in regular maths:
- Addition (+): Adds two numbers together
- Subtraction (-): Takes one number away from another
- Multiplication (*): Multiplies two numbers (notice we use * instead of ×)
- Division (/): Divides one number by another and gives a decimal result
In programming, we use different symbols than traditional mathematics. For example, we use * for multiplication instead of × because × isn't available on most keyboards!
Special arithmetic operators
Programming languages also include some special arithmetic operators that you might not have seen before:
- Modulus (%): This finds the remainder after division. For example, 7 % 3 = 1 because when you divide 7 by 3, you get 2 remainder 1
- Integer division (//): This divides numbers but only gives you the whole number part, ignoring any decimal places. For example, 7 // 3 = 2
- Exponentiation (**): This calculates powers. For example, 2 ** 3 = 8 (which means )
Don't confuse the modulus (%) operator with percentage calculations! The modulus operator finds remainders, not percentages.
Relational operators
Relational operators help us compare different pieces of data. They're essential for making decisions in programmes using selection statements like if...else.

Understanding comparison operators
Each relational operator compares two values and gives a true or false result:
- Equal to (==): Checks if two values are exactly the same
- Not equal to (!=): Checks if two values are different
- Less than (<): Checks if the first value is smaller than the second
- Less than or equal (<=): Checks if the first value is smaller than or the same as the second
- Greater than (>): Checks if the first value is bigger than the second
- Greater than or equal (>=): Checks if the first value is bigger than or the same as the second
Notice that to check if two values are equal, we use == (two equals signs), not just = (one equals sign). A single = is used for assigning values to variables!
Comparing strings
An important thing to remember is that relational operators don't just work with numbers - they can also compare text (strings). When comparing strings, the computer uses alphabetical order. For example, "David" comes after "Catherine" in the alphabet, so "David" > "Catherine" would be true. Similarly, "Db" > "Da" because 'b' comes after 'a' in the alphabet.
String comparison is case-sensitive! This means "Apple" and "apple" are considered different. Capital letters come before lowercase letters in the computer's ordering system.
Order of operations
Just like in regular mathematics, when you're writing calculations in programmes, you need to follow the correct order of operations. We use BIDMAS to remember this:
- Brackets - Work out anything in brackets first
- Indices or powers - Calculate any powers or square roots
- Division - Do division operations
- Multiplication - Do multiplication operations
- Addition - Do addition operations
- Subtraction - Do subtraction operations
Getting the order wrong can completely change your answer, so always check your calculations follow BIDMAS! For example: (not 20), because multiplication comes before addition.
Worked examples
Worked Example: Using Integer Division
A chocolate factory packs 20 bars of chocolate into each box. An algorithm stores the number of bars packed per day in a variable called numBars. We need to construct an expression to calculate the number of full boxes produced in a day.
Solution: numberBoxes = numBars // 20
The key here is using integer division (//) because we only want to count complete boxes. If we had 50 bars, regular division (50 / 20 = 2.5) would give us 2.5 boxes, but we can only make 2 full boxes. Integer division gives us exactly 2.
Worked Example: Using Relational Operators in Selection
Here's an algorithm that demonstrates how relational operators work in conditional statements:
1 num = int (input ("Number: "))
2 if (num > 5):
3 print ("Higher than 5")
4 elif (num < 5):
5 print ("Lower than 5")
6 else:
7 print ("You entered 5")
When the user enters -12, the output would be "Lower than 5" because -12 < 5 is true.
This example shows how we use the > and < operators to compare the user's input with the value 5. Notice that we don't need the == operator in the else statement because if the number isn't greater than 5 and isn't less than 5, it must equal 5.
Practice question
Test Your Understanding
Try this question to test your understanding:
Describe the difference between the arithmetic operators modulus (%) and integer division (//).
Hint: Think about what each operator returns when you divide one number by another.
Key Points to Remember:
- Arithmetic operators perform mathematical calculations in programmes (like +, -, *, /, %, //, **)
- Relational operators compare values and return true or false results (like ==, !=, <, >, <=, >=)
- BIDMAS determines the correct order for mathematical operations
- String comparisons use alphabetical order, not numerical value
- Integer division (//) only gives whole numbers, while modulus (%) gives remainders