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 | AWrong comparison: > is used when finding the minimum. It should be < so Min is replaced only by a smaller value. | |
| 2FOR Index ← 1 TO 10 (array has 10 items) | BSets the running total to zero before the loop, so old or unknown values are not added to the answer | |
| 3To find the maximum, start Max with the first array item, not 0, so negative numbers or low values still work | CThe Found flag is never set to FALSE before the loop and the position is not stored, so the result may be wrong or the location is lost. | |
| 4To calculate an average, divide once after the loop has finished, not inside the loop | DThe loop bounds match the array size, so every item is visited and the loop never runs past the end | |
| 5IF Numbers[Index] > Min THEN Min ← Numbers[Index] ENDIF | EMax ← Numbers[1] | |
| 6IF Names[Index] = Target THEN Found ← TRUE ENDIF (Index never updated, Found never set to FALSE first) | FNEXT Index Average ← Total / Count |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
logic error — A mistake in an algorithm's steps that lets it run but gives wrong results, e.g. a total not set to 0, a loop going past the array end, or using > instead of <.Total ← 0
FOR Index ← 1 TO 5
Total ← Total + Mark[Index]DECLARE Mark : ARRAY[1:5] OF INTEGER
FOR Index ← 1 TO 5
Total ← Total + Mark[Index]Min ← Score[1]
FOR i ← 2 TO 5
IF Score[i] < Min THEN Min ← Score[i] Total ← Total + Score[i]
NEXT i
Average ← Total / 5IF Name[i] = Target THEN
Found ← TRUE
ENDIF