Still loading. This can take a moment on a slow connection.
Still loading. This can take a moment on a slow connection.
Unit 7 · Algorithm Design and Problem-Solving
Step through a FOR loop that builds up a total, and predict the total and whether the loop goes round again at each pass.
StartThe program is about to run, from line 1.
DECLARE Total : INTEGERDECLARE Index : INTEGERTotal ← 0FOR Index ← 1 TO 5 Total ← Total + IndexNEXT IndexOUTPUT "Total: ", Total| Total | — |
|---|---|
| Index | — |
Before a line runs, say what it will do: the value it stores, what it outputs, or whether a test is TRUE. Play waits for your answer.
After your first prediction, this says why it works.
Try what you found on the lesson’s 36 marked questions. Practise in Trace Tables
Key
A teaching interpreter for the pseudocode the 0478 syllabus writes. It runs a program a line at a time, and stops one that takes more than 2000 steps or outputs more than 200 lines. Names are not case-sensitive, as the syllabus says. An input is read as the data type its variable was declared with. Files are held in the page: each run starts from the files under Files, and nothing is saved. When a FOR loop ends, its counter keeps the last value it ran with.