← IGCSE Computer Science Paper 2

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.

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 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.

Learning
Duo
Which line correctly calculates an average in IGCSE pseudocode?
Average = Total / CountAverage ← Total / Count
Matches
Average ← Total + Count / Count
↓
Without brackets, the division happens first, so only Count / Count is divided and the result is wrong. It must be Total / Count, or use brackets such as (Total + Extra) / Count if more is added.
Applying
Meanings
Term
Average ← Total / Count
Meaning
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.
Practice
DECLARE Average : REAL
Testing
Gaps
Average ← / Count
Check Answer
Spots
1DECLARE Average : INTEGER
2Average ← Total / Count

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

The 'Gulper Eel' badge — Deep Streak, 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. Which line correctly calculates an average in IGCSE pseudocode?
A. Average ← Total / Count ✓
B. Average = Total / Count
Assignment uses the ← arrow. A single = is used for comparison, not for storing a value.
2. Where should the average be calculated in a loop that adds up marks?
A. Inside the loop on every repeat
B. After the loop has finished ✓
Total and Count are only complete once the loop ends. Work out the average after ENDWHILE or NEXT.
3. An average is worked out by...
A. dividing the total by the count ✓
B. multiplying the total by the count
Average = Total / Count. For example, a total of 60 over 4 values gives 15.
4. Which check stops the program dividing by zero?
A. IF Total > 0 THEN
B. IF Count > 0 THEN ✓
The divisor is Count, so Count is what must be checked. Total can be 0 while Count is not, and that is safe.
5. Which data type should the Average variable have?
A. DECLARE Average : REAL ✓
B. DECLARE Average : INTEGER
An average often has decimal places, such as 7.5. An INTEGER cannot store those, so use REAL.

Match the Pairs

Average ← Total / Count → Divides the total of all the values by how many values there were, and stores the result in Average
IF Count > 0 THEN Average ← Total / Count ENDIF → Only works out the average when at least one value was entered, so it never divides by zero
The average is calculated after the loop has finished, once Total and Count are complete → ENDWHILE Average ← Total / Count
The result of a division can have decimal places, so the variable is declared as REAL → DECLARE Average : REAL
Average ← Total + Count / Count → Without brackets, the division happens first, so only Count / Count is divided and the result is wrong. It must be Total / Count, or use brackets such as (Total + Extra) / Count if more is added.
FOR Number ← 1 TO 10 Total ← Total + Number Average ← Total / Count NEXT Number → The average is calculated inside the loop, so it is worked out before all the values have been added. It should be calculated once after NEXT, when the loop has finished.

Key Term

Average ← Total / Count
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.

Fill in the Blanks

1. Average ← Total / Count
Hint: Type the variable that holds the sum of all the values.
2. Average ← Total / Count
Hint: Type the pseudocode assignment symbol (typed as <-).
3. IF Count <> 0 THEN Average ← Total / Count ENDIF
Hint: Type the relational operator that checks Count is not equal to zero, so you avoid dividing by zero.
4. DECLARE Average : REAL
Hint: Type the data type that can store a result with decimal places.
5. Average ← (Total + Bonus) / Count
Hint: Type the symbol that makes the addition happen before the division.

Spot the Error

Question 1
A DECLARE Average : INTEGER
B Average ← Total / Count
C OUTPUT Average
Line A — An average is often not a whole number, so it must be stored in a REAL variable. It should be DECLARE Average : REAL.
Question 2
A Count ← 5
B Average ← Total * Count
C OUTPUT Average
Line B — An average is the total divided by the count, not multiplied. It should be Average ← Total / Count.
Question 3
A INPUT Total
B INPUT Count
C IF Count = 0 THEN
D Average ← Total / Count
E ENDIF
Line C — The division must only happen when Count is not 0, to avoid dividing by zero. The condition should be IF Count <> 0 THEN.
Question 4
A INPUT Mark1
B INPUT Mark2
C Average ← Mark1 + Mark2 / 2
D OUTPUT Average
Line C — Without brackets, only Mark2 is divided by 2 because division is done before addition. It should be Average ← (Mark1 + Mark2) / 2.
Question 5
A DECLARE Average : REAL
B Average = Total / Count
C OUTPUT "Average: ", Average
Line B — Assignment uses the arrow ←, not =. It should be Average ← Total / Count.

Student with a class code? Join your class →