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 | |
|---|---|---|
| 1Max ← Numbers[1] | AMax ← Num | |
| 2IF Numbers[Index] > Max THEN Max ← Numbers[Index] | BStarting Max at 0 fails when all values are negative. Max would stay 0, which is not in the list. Start with Max ← Numbers[1]. | |
| 3Compare each later value with the largest so far by looping from the second item to the last | CReplace the largest value so far when a later value is bigger | |
| 4Keep the largest value seen so far in a variable which is updated when a bigger value is found | DStart the maximum with the first value in the list, so it is a real value from the data | |
| 5Max ← 0 FOR Index ← 1 TO 5 IF Numbers[Index] > Max THEN Max ← Numbers[Index] NEXT Index | EFOR Index ← 2 TO 5 | |
| 6IF Num < Max THEN Max ← Num | FThe wrong comparison is used. < finds a smaller value, so this finds the minimum. It should be IF Num > Max. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
IF Num > Max THEN Max ← Num — Keep the largest value seen so far in Max. Start Max with the first value, then replace it whenever a later value is larger. Starting at 0 can fail if all values are negative.Max ← Numbers[1]Max ← Numbers[1]
FOR Index ← 2 TO 5FOR Index ← 2 TO 5
IF Numbers[Index] > Max THEN
Max ← Numbers[Index]IF Numbers[Index] > Max THEN
Max ← Numbers[Index]
ENDIFNEXT Index
OUTPUT "Largest: ", Max