Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
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 i ← 1 TO 5 | AFOR Count ← 4 TO 11 | |
| 2FOR i ← 5 TO 1 | BThe loop body runs zero times, because the start value is bigger than the end value | |
| 3When the start and end values are equal, the loop runs exactly once | COff-by-one error: 1 TO 10 runs 10 times, not 9. The count was worked out as end - start and the + 1 was forgotten. | |
| 4The number of repetitions is end - start + 1, so this loop runs 8 times | DThe loop body runs 5 times, because 5 - 1 + 1 = 5 | |
| 5FOR i ← 1 TO 10 // meant to run 9 times | EFOR i ← 3 TO 3 | |
| 6FOR i ← 10 TO 1 // meant to run 10 times | FThe start value is bigger than the end value, so the loop runs zero times instead of 10. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
end - start + 1 — The number of times a FOR loop runs. FOR i ← 1 TO 5 runs 5 times, 3 TO 3 runs once, and 5 TO 1 runs zero times because the start value is bigger than the end value.FOR i ← 1 TO 5
OUTPUT i
NEXT iFOR i ← 3 TO 3
OUTPUT i
NEXT iFOR i ← 5 TO 1 // runs 0 times
OUTPUT i
NEXT iFOR i ← 3 TO 8 // runs 8 - 3 + 1 times
OUTPUT i
NEXT iFOR i ← 0 TO 9 // runs 10 times
OUTPUT i
NEXT i