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 | |
|---|---|---|
| 1REPEAT 5 TIMES -> 5 rows | AA loop that repeats 5 times needs one row in the trace table for each pass, so the table has 5 rows. | |
| 2i=3 | i>2 true | count=2 | BOUTPUT total (last row: total = 9) | |
| 3The IF condition is checked on every pass, so each row records true or false for that pass. | COn pass 3 the condition is true, so the count variable changes and the new value is written in that row. | |
| 4After the last pass, the final row gives the output once the loop has finished. | DFOR n = 1 TO 4: IF n > 2 -> F, F, T, T | |
| 5One row for a loop that runs 4 times, showing only the final count | EThe row does not show whether the IF condition was true or false, so we cannot tell why count did or did not change. | |
| 6Pass 2: n=2, count=1 (no condition result shown) | FThe trace skips the passes. Each repeat needs its own row showing the condition result and changed variables. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
one row per pass — Trace an IF inside a loop with one row for each pass, showing the condition result (true or false) and any variables that change. The final row gives the output.total ← 0
FOR n ← 1 TO 4
IF n > 2 THEN total ← total + nIF n > 2 THEN total ← total + n
Pass 2: n = 2, n > 2 is false, total = 0IF n > 2 THEN total ← total + n
Pass 3: n = 3, true, total = 3
Pass 4: n = 4, true, total = 7Pass 4: n = 4, true, total = 7
OUTPUT total
Final row: output is 7count ← 0
FOR n ← 1 TO 4
IF n < 3 THEN count ← count + 1