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 <- 0 | ATotal <- 0 INPUT Number WHILE Number <> -1 DO Total <- Total + Number INPUT Number ENDWHILE OUTPUT Total | |
| 2Total <- Total + Number | BTotal <- 0 is inside the loop, so the total is reset to zero on every repeat and only the last number is kept. It should be placed before the loop. | |
| 3Totalling ten values typed in by the user: set the total to 0, then add each input inside a FOR loop | CAdds the new value to the running total and stores the result back in Total each time round the loop | |
| 4Totalling until a rogue value is entered, then showing the total after the loop has finished | DTotal <- Number replaces the total with the latest value instead of adding to it. It should be Total <- Total + Number. | |
| 5FOR Count <- 1 TO 5 Total <- 0 INPUT Number Total <- Total + Number NEXT Count | ETotal <- 0 FOR Count <- 1 TO 10 INPUT Number Total <- Total + Number NEXT Count | |
| 6Total <- 0 FOR Count <- 1 TO 5 INPUT Number Total <- Number NEXT Count | FSets the running total to zero before the loop starts, so the adding begins from a known value |
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 — Adds each new value to the running total inside a loop. Set Total <- 0 before the loop starts, then OUTPUT Total after the loop ends.Total <- 0
FOR Count <- 1 TO 5
INPUT NumberFOR Count <- 1 TO 5
Total <- Total + Number
NEXT Count INPUT Number
Total <- Total + Number
NEXT CountWHILE Number <> -1 DO
Total <- Total + Number
INPUT NumberNEXT Count
OUTPUT "Sum: ", Total