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 Count ← 1 TO 3 | ATrace this loop with Num = 2, then 6, then 10, because STEP 4 adds 4 each time, giving 3 passes. | |
| 2FOR Num ← 2 TO 10 STEP 4 | BSTEP 2 was ignored. The loop variable should go up by 2 each pass, giving 1, 3, 5, 7, 9 and not every number. | |
| 3Every pass of the loop body gets its own row, with the loop variable column showing the current value for that pass. | CFOR Count ← 1 TO 4 OUTPUT Count * 2 NEXT Count | |
| 4A FOR loop that counts down uses a negative STEP, so the loop variable is traced with 5, 4, 3, 2, 1. | DFOR Num ← 5 TO 1 STEP -1 OUTPUT Num NEXT Num | |
| 5FOR Count ← 1 TO 3 gives rows with Count = 1, 2, 3, 4 | EThe trace goes one value too far. The loop variable stops at the end value 3, so there are only 3 passes and no row for 4. | |
| 6FOR Num ← 1 TO 9 STEP 2 gives rows with Num = 1, 2, 3, 4, 5 | FTrace this loop with Count = 1, then 2, then 3, running the loop body once for each value and using one row per pass. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
FOR Count ← 1 TO 5 — To trace a FOR loop, give the loop variable each value from start to end in turn, run the loop body once for each value, and record every pass in its own row of the trace table.FOR Count ← 1 TO 5
OUTPUT Count
NEXT CountFOR Count ← 1 TO 5
OUTPUT Count
NEXT CountFOR Count ← 1 TO 10 STEP 3
OUTPUT Count
NEXT CountFOR Num ← 1 TO 3
Total ← Total + Num
NEXT NumFOR Count ← 5 TO 1 STEP -1
OUTPUT Count
NEXT Count