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 ← Total + Number | ATotal was never set to 0 before the loop, so the first row of the trace table has no valid starting value and the totals will be wrong. | |
| 2Total ← 0 | BFOR Count ← 1 TO 3 INPUT Number Total ← Total + Number NEXT Count | |
| 3For the values 4, 6 and 5, the Total column reads 0, 4, 10, 15 because the total grows after each value is added | CTotal ← 0 FOR Count ← 1 TO 5 Total ← Total + Number[Count] NEXT Count | |
| 4The total must be set to 0 before the loop starts so the first row of the trace table has a correct starting value | DThe total is added after the loop, so the Total column only changes once at the end and does not grow on each pass. The line should be inside the loop. | |
| 5FOR Count ← 1 TO 3 INPUT Number NEXT Count Total ← Total + Number | ESets the Total column to 0 in the first row of the trace table, before any values are added | |
| 6FOR Count ← 1 TO 3 INPUT Number Total ← Total + Number NEXT Count | FOn each pass, the Total column shows the old total plus the new Number, so it grows row by row in the trace table |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Total ← Total + Number — In a trace table, this line makes the Total column grow by the new Number on every pass. Total must start at 0 before the loop, and this line must sit inside the loop.Total ← 0
FOR Count ← 1 TO 4
INPUT NumberFOR Count ← 1 TO 4
Total ← Total + Number
NEXT CountFOR Count ← 1 TO 4
Total ← Total + Number
NEXT CountFOR Count ← 1 TO 4
Total ← Total + Number
NEXT CountNEXT Count
OUTPUT Total