Totalling the elements of an array
Adds the current element to the running total on each loop pass. Set Total ← 0 before the loop first, or the answer will be wrong. Divide by the number of elements for the average.
Understanding Totalling the elements of an array in IGCSE Computer Science Paper 2
What it does: The average is the total divided by the number of elements, here 10 elements, and it is calculated after the loop. The loop visits every index from 1 to 10 and adds each element Marks[Index] to Total once. An unset or leftover value in Total gets included in the sum, so the answer is wrong. The loop itself still runs. Total ← 0 initialises the running total before any elements are added to it. The total must be reset before the loop, not inside it. Otherwise earlier additions are lost. Without initialising Total to 0, the running total begins from an undefined value, so the sum is incorrect.
Common mistakes: The running total must start at 0. Starting at 1 makes the final total 1 too big. It should be Total ← 0. = is a comparison, not an assignment. Pseudocode uses ← to set the total, so the line should be Total ← 0.
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 459–468) and word search (Modules 459–478).
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
Total ← Total + Marks[Index]Fill in the Blanks
Spot the Error
Student with a class code? Join your class →