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 | |
|---|---|---|
| 1Total | Count | OUTPUT (column headings) | AThe rows are out of order. The OUTPUT was written before the assignments that create the value had been traced. | |
| 2FOR Count ← 1 TO 3 (one new row each time a value changes) | BFOR Num ← 1 TO 4 IF Num MOD 2 = 0 THEN Total ← Total + Num ENDIF NEXT Num | |
| 3Work through a loop with an IF: on each pass, test the condition and only update the variable when it is true | CTotal ← 0 FOR Num ← 1 TO 3 Total ← Total + Num NEXT Num OUTPUT Total | |
| 4After the last row, check the final values: the last entry in each column is the final value of that variable and the OUTPUT column shows what was displayed | DThe IF condition was not tested, so every Num was added to Total. Only the even values (2) should have changed Total. | |
| 5Num=1, Total=1 | Num=2, Total=3 | Num=3, Total=6 (for a loop with an IF that only adds even numbers) | EFill in the rows in the same order the algorithm runs, so each loop pass adds new rows in sequence. | |
| 6Row 1: OUTPUT 6, Row 2: Total ← 0 (for an algorithm that sets Total to 0, then adds, then outputs) | FThe trace table has one column for each variable and one for OUTPUT, so every change can be recorded. |
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 for a dry run: follow the algorithm line by line with the given inputs, writing each variable, output and prompt in the order it happens, then check the final values.FOR Count ← 1 TO 3
Total ← Total + Count
NEXT CountIF Number MOD 2 = 0 THEN
OUTPUT "Even"
ENDIFWHILE Total < 10 DO
Total ← Total + 4
ENDWHILEOUTPUT "Enter a number"
INPUT Number
OUTPUT Number * 2FOR Count ← 1 TO 4
IF Count > 2 THEN OUTPUT Count
NEXT Count