Calculating an average in Cambridge pseudocode
Divides the finished Total by Count after the loop ends, giving the mean. Declare Average as REAL. Check Count > 0 first to avoid dividing by zero.
Understanding Calculating an average in Cambridge pseudocode in IGCSE Computer Science Paper 2
What it does: The division comes after NEXT, when the loop has added up all the values. It is not inside the loop. The IF stops the division from running when Count is 0, because dividing by zero causes an error. An average often has decimal places, for example 74.5, so it should be declared as REAL. The variable being assigned goes on the left of the arrow, and the calculation goes on the right. Divide by the number of items, 5. You cannot divide by the array name itself. 240 divided by 4 is 60. Adding the numbers instead of dividing is a common mistake.
Common mistakes: A FOR loop must use ← to set the start value. It should be FOR Index ← 1 TO 5. An average is often a decimal such as 15.5, so Average must be declared as REAL, not INTEGER.
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 286–295) and word search (Modules 275–295).
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
Average ← Total / CountFill in the Blanks
Spot the Error
Student with a class code? Join your class →