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 Row ← 1 TO 3 FOR Column ← 1 TO 4 OUTPUT Row * Column NEXT Column NEXT Row | AThe NEXT statements are in the wrong order. The inner loop must be closed first, so NEXT Column comes before NEXT Row. | |
| 2NEXT Column NEXT Row | BFOR Row ← 1 TO 2 FOR Column ← 1 TO 3 OUTPUT Column NEXT Column NEXT Row | |
| 3The inner loop is indented four more spaces than the outer loop, and its body four more again | CA nested loop: the inner Column loop runs 4 times for each of the 3 Row passes, so OUTPUT runs 3 x 4 = 12 times | |
| 4Total passes = outer passes x inner passes, so an outer loop of 5 and an inner loop of 2 give 10 passes | DEach loop closes with its own NEXT, the inner loop first and then the outer loop | |
| 5FOR Row ← 1 TO 3 FOR Column ← 1 TO 4 OUTPUT Row * Column NEXT Row | EThe inner loop has no NEXT Column. Each loop needs its own NEXT, so NEXT Column must be added before NEXT Row. | |
| 6FOR Row ← 1 TO 3 FOR Column ← 1 TO 4 OUTPUT Row * Column NEXT Row NEXT Column | FFOR Row ← 1 TO 5 FOR Column ← 1 TO 2 OUTPUT "*" NEXT Column NEXT Row |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
nested loop — A loop placed inside another loop. The inner loop runs completely for every pass of the outer loop, so total passes = outer passes x inner passes.FOR Row ← 1 TO 3
FOR Column ← 1 TO 4
OUTPUT Row * Column OUTPUT Row * Column
NEXT Column
NEXT Row FOR Column ← 1 TO 4
OUTPUT Row * Column
NEXT Column OUTPUT Row * Column
NEXT Column
NEXT RowRows ← 3
Cols ← 4
Total ← Rows * Cols