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 | |
|---|---|---|
| 1FOR Index ← 1 TO 30 StudentNames[Index] ← "" NEXT Index | AFOR Index ← 1 TO 30 | |
| 2Scores[Index] ← 0 | BThe loop limit 31 is larger than the upper bound 30 of the array, so the last pass writes to an index that does not exist and causes an index out of range error. It should be TO 30. | |
| 3The loop limits must match the array bounds, so an array declared as ARRAY[1:30] is filled by a loop from 1 to 30 | CFOR Index ← 1 TO 30 Scores[Index] ← 0 NEXT Index | |
| 4A FOR loop can set every element of a Scores array to 0 by using the loop variable as the index | DSets all 30 elements of StudentNames to an empty string, one element on each pass of the loop | |
| 5FOR Index ← 1 TO 31 Scores[Index] ← 0 NEXT Index | EAssigns 0 to the element at the position held in Index; inside a FOR loop this resets one element per pass | |
| 6FOR Index ← 1 TO 30 Scores[1] ← 0 NEXT Index | FThe fixed index 1 means only the first element is set, thirty times. It should use the loop variable: Scores[Index] ← 0. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
FOR Index ← 1 TO 30 — A loop that uses its counter as the array index, so each pass assigns a value to one element, e.g. Scores[Index] ← 0. The loop limits must match the array bounds.FOR Index ← 1 TO 30
Scores[Index] ← 0
NEXT IndexFOR Index ← 1 TO 30
StudentNames[Index] ← ""
NEXT Index// Scores : ARRAY[0:9] OF INTEGER
FOR Index ← 0 TO 9
Scores[Index] ← 0FOR Index ← 1 TO 30
Scores[Index] ← 0
NEXT IndexFOR Index ← 1 TO 30
Scores[Index] ← 0
NEXT Index