3. Using arrays
Declaring arrays
Before you can use an array, you have to tell the program that it actually is an array, rather than some other kind of variable. This is called declaring an array. If you don't have any values to put in yet, you can just declare an empty array, like this:
array MyArray []
Getting the length of an array
Most programming languages allow you to get the length of an array while the program is running, whether that array is static or dynamic.
For the AQA syllabus, the pseudocode to get the length of something is LEN(something)
In the case of an array called MyArray this is the pseudocode:
LEN(MyArray)
Knowing the length of an array is useful for things like loops, where you want to keep running code until it reaches the end of the array. For example:
loopcount
LEN(MyArray) - 1
FOR x
0 TO loopcount:
OUTPUT MyArray[x]
ENDFOR
