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 | |
|---|---|---|
| 1Count ← 0 and Total ← 0 | AIF Number > 50 THEN Count ← Count + 1 ENDIF | |
| 2Total ← Total + Number | BThe first row of the trace table: both columns start at 0 before the loop runs | |
| 3The counter only changes on a pass when the IF condition is true, so its column stays the same on other rows | CThe counter and total must start at 0 in the initialisation row. Starting at 1 gives every later row the wrong value. | |
| 4The final Count and Total are written in the OUTPUT column after the loop has finished, not during it | DA new Total value is written in the table on every pass of the loop | |
| 5Row 1 of the trace table: Count = 1, Total = 1 (before any numbers are read) | ENEXT Index OUTPUT Count, Total | |
| 6Number = 40, IF Number > 50 is false, but Count goes from 2 to 3 | FCount must not change when the IF condition is false. It should stay at 2 on this row. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Count ← Count + 1 — Trace table for counting and totalling: Count and Total start at 0 in the first row, change each pass (Count only if the IF is true), and the final values are output after the loop.Count ← 0
Total ← 0IF Mark >= 50 THEN
Count ← Count + 1
ENDIFINPUT Mark
Total ← Total + Mark
OUTPUT TotalIF Mark >= 50 THEN
Count ← Count + 1
ENDIFNEXT Index
OUTPUT "Count: ", Count
OUTPUT "Total: ", Total