Pseudocode: presenting query results
Loops through the returned records, printing each as a formatted line under a heading, then prints a summary such as a count or total. If there are none, print a no results message.
Understanding Pseudocode: presenting query results in QCE Digital Solutions Unit 2
What it does: Checking whether the count is 0 lets the program tell the user nothing matched rather than showing a blank screen. The summary is printed once after all the lines, using the counter that was increased inside the loop. Formatting joins the chosen fields with separators so each line is easy to read. Printing the whole record does not control the layout. Adding to total each pass accumulates the sum. Assigning only record.mark overwrites the total each time. The no results message should show only when the count is 0. Using > 0 would show it when there are results. A heading row is printed one time above the records so the student can tell what each field shows.
Common mistakes: The heading line must be a fixed text string. This line uses r.name and r.mark before the loop has created r, so it would fail. It should be print "Name Mark". A for each loop header does not use the word then, because then belongs to an if statement. It should be for each r in results.
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 234–285) and word search (Modules 234–409).
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 resultsFill in the Blanks
Spot the Error
Student with a class code? Join your class →