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 | |
|---|---|---|
| 1Largest ← Marks[1] | ALargest has no starting value, so the first comparison uses an undefined value. It should be set first with Largest ← Marks[1]. | |
| 2IF Marks[Index] > Largest THEN Largest ← Marks[Index] ENDIF | BCompare the current mark with Largest and replace Largest only if the current mark is bigger. | |
| 3The loop can start at the second element because the first element was already stored in Largest. | CFOR Index ← 2 TO 10 | |
| 4To also record where the maximum is, save the Index whenever a new largest value is found. | DStart by assuming the first mark is the biggest so far, so Largest has a real value from the array to compare against. | |
| 5FOR Index ← 2 TO 10 IF Marks[Index] > Largest THEN Largest ← Marks[Index] ENDIF NEXT Index OUTPUT Largest (Largest was never set before the loop) | EOUTPUT Largest is inside the loop, so it prints after every item. It should come after NEXT Index so the final maximum is output once. | |
| 6FOR Index ← 2 TO 10 IF Marks[Index] > Largest THEN Largest ← Marks[Index] ENDIF OUTPUT Largest NEXT Index | FIF Marks[Index] > Largest THEN Largest ← Marks[Index] Position ← Index ENDIF |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
IF Marks[Index] > Largest THEN Largest ← Marks[Index] ENDIF — Used inside a loop to compare each mark with Largest. If the mark is bigger, it replaces Largest. When the loop ends, Largest holds the biggest value in the array.Largest ← Marks[1]FOR Index ← 2 TO 10
IF Marks[Index] > Largest THEN
Largest ← Marks[Index]FOR Index ← 2 TO 10
IF Marks[Index] > Largest THEN
Largest ← Marks[Index]IF Marks[Index] > Largest THEN
Largest ← Marks[Index]
ENDIFNEXT Index
OUTPUT Largest