Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Working out how many elements an array holds worksheet is part of the IGCSE Computer Science 0478 — 8.2 Arrays journey. Print it as a booklet?
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 | |
|---|---|---|
| 1ARRAY[1:30] OF STRING | AHolds 30 elements, because 30 - 1 + 1 = 30 | |
| 2ARRAY[5:9] OF INTEGER | BThe upper bound is not the size when the lower bound is not 1. The correct size is 9 - 5 + 1 = 5 elements. | |
| 3A lower bound of 0 means the size is one more than the upper bound, so an array with 10 elements ends at index 9 | CThis forgets to add 1. The correct calculation is 9 - 0 + 1 = 10 elements. | |
| 4The number of elements is the upper bound minus the lower bound plus one | DHolds 5 elements (indexes 5, 6, 7, 8 and 9) | |
| 5ARRAY[0:9] holds 9 elements because 9 - 0 = 9 | ESize <- 30 - 1 + 1 | |
| 6ARRAY[5:9] holds 9 elements because the upper bound is 9 | FDECLARE Scores : ARRAY[0:9] OF INTEGER |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
upper - lower + 1 — The number of elements in a 1D array: upper bound minus lower bound plus one. ARRAY[0:9] holds 9 - 0 + 1 = 10 elements, and ARRAY[5:9] holds 5.// ARRAY[0:9]
Elements ← 9 - 0 + 1Size ← upper - lower + 1Size ← 9 - 5 + 1
// ARRAY[5:9] holds 5 elementsDECLARE Scores : ARRAY[5:9] OF INTEGER
// holds 5 elementsDECLARE Names : ARRAY[0:29] OF STRING
// holds 30 elements