Arrays in pseudocode

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Arrays in pseudocode

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Do array elements use square brackets like scores[1]?
A No
B Yes
2. Is round-bracket syntax like scores(1) valid for arrays?
A No
B Yes
3. Does DECLARE scores[5] OF INTEGER declare an array of 5 integers?
A Yes
B No
4. Is the ← arrow used to assign values to array elements?
A Yes
B No
5. Does a FOR loop over an array end with END FOR?
A No
B Yes

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1scores[1] ← 10 AWrong - array elements use square brackets, not round
2DISPLAY scores[i] BDECLARE scores[5] OF INTEGER
3Declares an array of 5 integers named scores CWrong - array declarations need a size in brackets
4Loops through every index in the array DAssigns the value 10 to the first array element
5scores(1) ← 10 EPrints the value stored at index i in the array
6DECLARE scores OF INTEGER FFOR i FROM 1 TO 5

Definitions

scores[1]

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
DECLARE scores[5] OF _______
2.
DISPLAY scores[_]
3.
FOR i FROM _ TO 5
4.
_______ scores[2]
5.
DECLARE scores[_] OF INTEGER

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A ARRAY scores[5] OF INTEGER
B scores[1] ← 10
C DISPLAY scores[1]
Question 2
A DECLARE scores[5] OF INTEGER
B scores(1) ← 10
C DISPLAY scores[1]
Question 3
A DECLARE scores[5] OF INTEGER
B scores[1] ← 10
C DISPLAY score[1]
Question 4
A DECLARE scores[5] OF INTEGER
B FOR i FROM 1 TO 5
C DISPLAY scores[i]
D END LOOP
Question 5
A DECLARE scores OF INTEGER
B scores[1] ← 10
C FOR i FROM 1 TO 5
D DISPLAY scores[i]

Answer Key

Arrays in pseudocode
Section A: Quick Questions
Q1
B — Yes
Q2
A — No
Q3
A — Yes
Q4
A — Yes
Q5
B — Yes
Section B: Match the Pairs
Q1
scores[1] ← 10 → Assigns the value 10 to the first array element
Q2
DISPLAY scores[i] → Prints the value stored at index i in the array
Q3
Declares an array of 5 integers named scores → DECLARE scores[5] OF INTEGER
Q4
Loops through every index in the array → FOR i FROM 1 TO 5
Q5
scores(1) ← 10 → Wrong - array elements use square brackets, not round
Q6
DECLARE scores OF INTEGER → Wrong - array declarations need a size in brackets
Section C: Definitions
Q1
scores[1] — Accesses the array element at index 1, using square brackets to specify the position.
Section D: Fill in the Blanks
Q1
DECLARE scores[5] OF INTEGER
Q2
DISPLAY scores[i]
Q3
FOR i FROM 1 TO 5
Q4
DISPLAY scores[2]
Q5
DECLARE scores[5] OF INTEGER
Section E: Spot the Error
Q1
A — Arrays are declared with DECLARE, not ARRAY, in VCAA pseudocode.
Q2
B — Array elements use square brackets, not round brackets.
Q3
C — The array name is misspelled - it should be scores, not score.
Q4
D — A FOR loop must close with END FOR, not END LOOP.
Q5
A — An array declaration needs a size in square brackets, like scores[5].