Calculating an average in pseudocode
An average is the total divided by the count. Work it out after the loop ends, and only when Count is not 0. Store it in a REAL variable.
Understanding Calculating an average in pseudocode in IGCSE Computer Science Paper 2
What it does: The calculation comes after ENDWHILE, so it runs once with the final Total and Count. An average is often not a whole number, so the variable that stores it must be REAL, not INTEGER. Assignment uses the ← arrow. A single = is used for comparison, not for storing a value. Average = Total / Count. For example, a total of 60 over 4 values gives 15. The divisor is Count, so Count is what must be checked. Total can be 0 while Count is not, and that is safe. Without brackets, division is done first, so only Bonus is divided. Brackets make the whole sum get divided.
Common mistakes: An average is often not a whole number, so it must be stored in a REAL variable. It should be DECLARE Average : REAL. An average is the total divided by the count, not multiplied. It should be Average ← Total / Count.
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 242–253) and word search (Modules 232–253).
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 →