← IGCSE Computer Science Paper 2

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.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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.

Learning
Duo
What is the value of 2 + 3 * 4 in Cambridge pseudocode?
1420
Matches
Average ← Mark1 + Mark2 / 2
↓
Without brackets, only Mark2 is divided by 2 and then added to Mark1, so this is not the average. It should be (Mark1 + Mark2) / 2.
Applying
Meanings
Term
(a + b) / 2
Meaning
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.
Practice
average ← (mark1 + mark2 + mark3) / 3
Testing
Gaps
Average ← (Maths + English) 2
Check Answer
Spots
1DECLARE Average : REAL
2Average ← A + B / 2

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Woodpecker' badge — Tap Tap Tap, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What is the value of 2 + 3 * 4 in Cambridge pseudocode?
A. 20
B. 14 ✓
Multiplication is worked out before addition, so 3 * 4 = 12, then 2 + 12 = 14.
2. What is the value of (2 + 3) * 4?
A. 14
B. 20 ✓
Brackets are worked out first, so 2 + 3 = 5, then 5 * 4 = 20.
3. Which operation is worked out first in 10 - 6 / 2?
A. 6 / 2 ✓
B. 10 - 6
Division comes before subtraction, so 6 / 2 = 3, then 10 - 3 = 7.
4. Which expression correctly works out the average of two marks, a and b?
A. (a + b) / 2 ✓
B. a + b / 2
Without brackets, only b is divided by 2. Brackets make the addition happen first.
5. What does a + b / 2 do when a = 10 and b = 20?
A. Gives 20, because only b is divided by 2 ✓
B. Gives 15, because a + b is divided by 2
Division happens first: 20 / 2 = 10, then 10 + 10 = 20. Use (a + b) / 2 to get 15.

Match the Pairs

2 + 3 * 4 → Multiplication happens first, so the result is 2 + 12 = 14
(2 + 3) * 4 → Brackets are worked out first, so the result is 5 * 4 = 20
Brackets make the order explicit, so the addition happens before the division when finding an average of two marks → Average ← (Mark1 + Mark2) / 2
Multiplication is worked out before subtraction, so the multiplication in this expression is done first → Result ← 10 - 2 * 3
Average ← Mark1 + Mark2 / 2 → Without brackets, only Mark2 is divided by 2 and then added to Mark1, so this is not the average. It should be (Mark1 + Mark2) / 2.
Total ← (2 + 3 * 4) should give 20 → Multiplication comes first, so this gives 14, not 20. To get 20, write (2 + 3) * 4.

Key Term

(a + b) / 2
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.

Fill in the Blanks

1. Average ← (Maths + English) / 2
Hint: Type the operator that divides the bracketed total by two.
2. Result ← 2 + 3 * 4 OUTPUT Result // Output is 14
Hint: Type the operator that is worked out before the addition to give the commented output.
3. Average ← (Test1 + Test2 + Test3) / 3 OUTPUT Average
Hint: Type the variable name that holds the calculated result so it can be output.
4. Average ← (Mark1 + Mark2 + Mark3) / 3
Hint: Type the number of values being added, which is what the total is divided by.
5. Result ← (10 - 4) / 2 // Result is 3
Hint: Type the operator that divides the bracketed result to give the commented value.

Spot the Error

Question 1
A DECLARE Average : REAL
B Average ← A + B / 2
C OUTPUT Average
Line B — 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.
Question 2
A DECLARE Result : INTEGER
B // add first, then multiply
C Result ← 2 + 3 * 4
D OUTPUT Result
Line C — 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.
Question 3
A DECLARE Mean : REAL
B Mean ← 10 + (20 + 30) / 3
C OUTPUT Mean
Line B — The brackets are in the wrong place. All three numbers must be added before dividing by 3, so it should be Mean ← (10 + 20 + 30) / 3.
Question 4
A Price ← 8
B Cost ← (Price + 2 * 3
C OUTPUT Cost
Line B — The opening bracket has no closing bracket. Brackets must come in matching pairs: Cost ← (Price + 2) * 3.
Question 5
A Hours ← 8
B Extra ← 2
C Rate ← 12
D Pay ← Hours + Extra * Rate
E OUTPUT Pay
Line D — Without brackets, Extra * Rate is worked out first, so Hours is not paid at the rate. Pay should be (Hours + Extra) * Rate.

Student with a class code? Join your class →