ARRAYS
When doing variables in loops, sometimes we may want to use the same variable name over and over again. Say you wanted to have a list of students in a class that is inputted by the keyboard or a file:
FOR X = 0 to 5 Get Student_NAME[X] NEXT X |
Student_NAME is an array of strings, and the way we access them is the index, or variable in the square brackets. When we use arrays, the first element of an array is usually variable[0].
2D Arrays
2D arrays are arrays with 2 indexes. Say we had an array with 25 elements to fill, 5 in the first index, 5 in the second index, and we would want to fill it up as quickly and efficiently as possible. We would do this using nested loops.
FOR X = 0 TO 5 FOR Y = 0 TO 5 Insignifigant_variable[X][Y] = X + Y NEXT Y NEXT X |
The previous example would take the two indexes and add them together. 2D arrays are used when we have data that is the same type and interact with eachother.