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 | |
|---|---|---|
| 1Average ← Total / Count | ADivides the total of all the values by how many values there were, and stores the result in Average | |
| 2IF Count > 0 THEN Average ← Total / Count ENDIF | BThe average is calculated inside the loop, so it is worked out before all the values have been added. It should be calculated once after NEXT, when the loop has finished. | |
| 3The average is calculated after the loop has finished, once Total and Count are complete | CWithout brackets, the division happens first, so only Count / Count is divided and the result is wrong. It must be Total / Count, or use brackets such as (Total + Extra) / Count if more is added. | |
| 4The result of a division can have decimal places, so the variable is declared as REAL | DENDWHILE Average ← Total / Count | |
| 5Average ← Total + Count / Count | EOnly works out the average when at least one value was entered, so it never divides by zero | |
| 6FOR Number ← 1 TO 10 Total ← Total + Number Average ← Total / Count NEXT Number | FDECLARE Average : REAL |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Average ← Total / Count — An average is the total divided by the count. Work it out after the loop ends, and only when Count is not 0. Store it in a REAL variable.Average ← Total / CountAverage ← Total / CountIF Count <> 0 THEN
Average ← Total / Count
ENDIFDECLARE Average : REALAverage ← (Total + Bonus) / Count