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 | |
|---|---|---|
| 1Marks[31] when Marks is ARRAY[1:30] | AIF Index >= 1 AND Index <= 30 THEN | |
| 2Marks[0] when Marks is ARRAY[1:30] | BThe index 11 is above the upper bound of 10, so the element does not exist. Use an index from 1 to 10. | |
| 3Check an index is at least the lower bound and at most the upper bound before using it | CIndex above the upper bound, so the element does not exist and the program gives an error | |
| 4An off-by-one mistake: the loop goes one step past the upper bound of ARRAY[1:30] | DIndex below the lower bound, so the element does not exist and the program gives an error | |
| 5DECLARE Scores : ARRAY[1:10] OF INTEGER Scores[10 + 1] <- 50 | EFOR Count <- 1 TO 31 | |
| 6DECLARE Names : ARRAY[1:5] OF STRING OUTPUT Names[0] | FThe index 0 is below the lower bound of 1, so the element does not exist. Use an index from 1 to 5. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
index out of range — An error caused by using an index below the lower bound or above the upper bound, so the element does not exist. Example: Marks[31] in ARRAY[1:30] or Marks[0] when the lower bound is 1.DECLARE Marks : ARRAY[1:30] OF INTEGER
Marks[31] ← 50DECLARE Marks : ARRAY[1:30] OF INTEGER
Marks[0] ← 50IF Index >= 1 AND Index <= 30 THEN
OUTPUT Marks[Index]
ENDIFDECLARE Marks : ARRAY[1:30] OF INTEGER
Marks[30] ← 100IF Index < 1 OR Index > 30 THEN
OUTPUT "Index out of range"
ENDIF