Worked example 1
A programmer is creating a game and needs to store the high scores of the top 5 players. The scores are whole numbers. Declare a suitable array to store these scores.
Show solution outline
// 1 mark for correct identifier, ARRAY keyword, and data type.
// 1 mark for correct bounds [1:5].
DECLARE HighScores : ARRAY[1:5] OF INTEGER
Explanation:
- DECLARE HighScores: We give the array a meaningful name.
- ARRAY[1:5]: We specify it's an array with 5 elements, indexed from 1 to 5. The lower bound is 1 and the upper bound is 5.
- OF INTEGER: We specify that each element will be a whole number.