Finding the maximum: how it works
Keep the largest value seen so far in Max. Start Max with the first value, then replace it whenever a later value is larger. Starting at 0 can fail if all values are negative.
Understanding Finding the maximum: how it works in IGCSE Computer Science Paper 2
What it does: Max already holds item 1, so the loop starts at 2 and compares every remaining value. This assignment inside the IF stores the new largest value so Max always holds the biggest seen so far. 9 is not larger than 14, so the IF Num > Max test is false. Max is only replaced when a larger value appears. Using < would keep the smaller value, which finds the minimum instead of the maximum. The maximum needs the test Num > Max.
Common mistakes: A FOR loop in Cambridge pseudocode sets its counter with the assignment arrow ←, not =. It should be FOR i ← 2 TO 5. The loop starts at 2 because Scores[1] is already in Max. Starting Max at 0 can fail. If every value is negative, none will beat 0 and the wrong answer stays in Max. Max should start with the first value, Max ← Ages[1].
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
IF Num > Max THEN Max ← NumFill in the Blanks
Spot the Error
Student with a class code? Join your class →