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 FROM 1 TO 4 / IF i > 2 THEN / total ← total + i | AThe condition is false, so the IF branch is skipped. Total should be copied down as 3, not changed to 5. | |
| 2Output column | Bi = 3 | i > 2 | true | |
| 3Copy unchanged values down: if the branch does not update a variable, write the same value in the next row. | CA loop that only adds to total when the condition is true. Rows 1 and 2 leave total unchanged, and rows 3 and 4 change it. | |
| 4Record the condition result in its own column for each repeat, as true or false, before updating any variables. | DThe column where you write anything the algorithm displays on that repeat, leaving it blank when nothing is shown. | |
| 5Row 2: i = 2, i > 2 is false, total changes from 3 to 5 | Ecount: 0, 0, 1, 1, 2 | |
| 6Stop tracing after the first row because the IF was false | FA trace must continue with one row for every loop repeat until the loop ends, even when the IF is false on some rows. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
trace table — A table with one row per loop repeat. Record the IF condition result, change only the variables the branch updates, copy the rest down, and note any output.Rule: IF n > 2 THEN total ← total + n
Row 1: n = 1, so the condition n > 2 is falseRule: IF n > 2 THEN total ← total + n
Row 3: n = 3, total before = 0
total after = 0 + 3Rule: IF n > 2 THEN total ← total + n
Row 4: n = 2, n > 2 is false
total before = 5, total after = 5IF n MOD 2 = 0 THEN
OUTPUT n
Row n = 4: output column shows 4Final row: count = 3, total = 9
Final values are read from the last row