Working out the purpose from a trace
Running an algorithm by hand with test values, then comparing the inputs with the final outputs to work out its purpose, such as totalling, counting or finding the largest.
Understanding Working out the purpose from a trace in IGCSE Computer Science Paper 2
What it does: Count goes up by 1 each time, not by the value itself, so tracing shows it counts items that meet the condition. Running test values shows Found becomes TRUE only when an item equals the target, so the purpose is a search. 4 + 7 + 2 = 13, so the output is the sum of the inputs. The largest input would be 7. Both outputs are the biggest number entered. The totals would be 17 and 26. One result can fit several purposes. Extra tests with different inputs show which purpose is really correct. 12, 15 and 20 are over 10, so the count is 3. The total of those would be 47.
Common mistakes: Each input is stored in Total instead of Number, so the old total is overwritten. With inputs 2, 4, 6 a dry run does not give 12. It should be INPUT Number so the algorithm totals the values. Mark is never read in, so there is no test value to trace. It should be INPUT Mark. With a mark of 60 the count goes 0 to 1, which shows the algorithm counts passes.
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 216–231) and word search (Modules 188–231).
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
dry runFill in the Blanks
Spot the Error
Student with a class code? Join your class →