Iterating through records in pseudocode
A loop that visits every record in an array once, so you can read, test or change each record's fields, such as counting or totalling the records that match.
Understanding Iterating through records in pseudocode in QCE Digital Solutions Unit 3
What it does: The loop visits every record, the if tests the house field, and the counter goes up only when the record matches. The index i selects one record at a time from the array, and .name reads that record's name field. An accumulator must add to its previous value. Writing total <- item.price overwrites it, so only the last price is kept. The loop variable takes each record in turn, one per pass. You then use p.fieldName to reach its fields. An index loop needs a number as the end value, such as the array length. An array is not a number, so it cannot be the limit.
Common mistakes: The loop header is missing the keyword 'in'. It should be 'for each s in students' so the loop visits every record in the students array. This overwrites total on every pass, so it only holds the last price. An accumulator must add to itself: total <- total + o.price.
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 194–250) and word search (Modules 194–337).
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
for each record in recordsFill in the Blanks
Spot the Error
Student with a class code? Join your class →