Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This FOR ... TO ... NEXT loop (7a) worksheet is part of the IGCSE Computer Science 0478 — 7a Program Development Life Cycle 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 Index ← 1 TO 30 | AFOR Index ← 10 TO 1 | |
| 2FOR Count ← 5 TO 5 | BRuns the loop body exactly once, because the start value and end value are equal | |
| 3A FOR loop must be closed with NEXT followed by the same loop variable | CFOR Index ← 1 TO 30 OUTPUT Index NEXT Index | |
| 4The loop does not run at all if the start value is bigger than the end value | DA FOR loop must end with NEXT Index, not ENDFOR. ENDFOR is not Cambridge pseudocode. | |
| 5FOR Index ← 1 TO 30 OUTPUT Index ENDFOR | ERepeats the statements below once for each integer from 1 to 30 inclusive, ending at NEXT Index | |
| 6FOR Index ← 1 TO 30 OUTPUT Index NEXT Count | FThe NEXT line uses a different identifier (Count) from the loop variable (Index). |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
FOR Index ← 1 TO 30 — Repeats the code once for each integer from 1 to 30 inclusive, up to NEXT Index. Runs once if both values are equal and not at all if the start value is bigger.FOR Index ← 1 TO 30
OUTPUT Index
NEXT IndexFOR Index ← 1 TO 30
OUTPUT Index
NEXT IndexFOR Index ← 1 TO 30
OUTPUT Index
NEXT IndexDECLARE Index : INTEGER
FOR Index ← 1 TO 30
NEXT IndexFOR Index ← 1 TO 1
OUTPUT "Hello"
NEXT Index