Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Using the FOR counter inside the loop worksheet is part of the IGCSE Computer Science 0478 — 8.1b Sequence, Selection and Iteration journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1FOR Count <- 1 TO 5 OUTPUT Count NEXT Count | AFOR Count <- 1 TO 3 OUTPUT Count NEXT Count OUTPUT Count | |
| 2OUTPUT Count * 7 | BOutputs the counter's value on each repeat, so it displays 1, 2, 3, 4, 5, one number per line | |
| 3The counter must not be changed by an assignment inside the loop body; the FOR loop controls it | CThe counter is changed inside the loop with an assignment. The FOR loop controls Count, so the body must never assign to it. | |
| 4After the loop finishes, the counter keeps its last value, so it can be output after NEXT | DThe times table uses a fixed value instead of the counter, so it does not show a new multiple on each repeat. | |
| 5FOR Count <- 1 TO 5 Count <- Count + 1 OUTPUT Count NEXT Count | EFOR Count <- 1 TO 12 OUTPUT Count * 7 NEXT Count | |
| 6FOR Count <- 1 TO 12 OUTPUT Count * 7 NEXT Count OUTPUT 7 | FUses the counter in a calculation inside the loop, so each repeat outputs the next multiple of 7 (a times table) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
OUTPUT Count * 7 — Uses the FOR counter inside the loop body. Count holds a new value on each repeat, so this outputs a times table. Never change Count inside the loop; after the loop it keeps its last value.FOR Count ← 1 TO 5
OUTPUT Count
NEXT CountFOR Count ← 1 TO 12
OUTPUT Count * 7
NEXT CountFOR Count ← 1 TO 12
OUTPUT Count * 7
NEXT CountFOR Count ← 1 TO 12
OUTPUT Count * 7
NEXT CountFOR Count ← 1 TO 12
OUTPUT Count * 7
NEXT Count