Order of operations and brackets
Brackets are worked out first, then * and / before + and -. So (a + b) / 2 adds first, then divides, giving an average. Without brackets, only b is divided by 2.
Understanding Order of operations and brackets in IGCSE Computer Science Paper 2
What it does: Putting Mark1 + Mark2 in brackets means the sum is worked out first and then divided by 2, which gives the average. Multiplication is worked out before addition, so 3 * 4 = 12, then 2 + 12 = 14. Division comes before subtraction, so 6 / 2 = 3, then 10 - 3 = 7. Division happens first: 20 / 2 = 10, then 10 + 10 = 20. Use (a + b) / 2 to get 15. Brackets are recommended in complex expressions because they make the intended order clear to anyone reading the code.
Common mistakes: Without brackets, B / 2 is worked out first and then added to A, so this is not the average. It should be Average ← (A + B) / 2 so the addition happens first. The comment says to add first, but without brackets 3 * 4 is done first, giving 14 instead of 20. The line should be Result ← (2 + 3) * 4.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 337–346) and word search (Modules 337–357).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
(a + b) / 2Fill in the Blanks
Spot the Error
Student with a class code? Join your class →