TOPIC 15.1.1
N-dimensional Arrays


The number of dimensions an array may have is almost endless. To add more dimensions to an array simply add more subscripts to the array declaration. The example below will show how this can be done.

This will declare an array of 50 states.

This will declare an array of 50 states each including 500 cities.

This will declare an array of 50 states each including 500 cities with a 1000 homes.

This will declare an array of 50 states each including 500 cities with a 1000 homes each containing 4 people.

When using this n-dimensional array, each person in the nation has a unique position in memory. For example to access the person in the second state, third city, eighth home, and the first person in the home the syntax would be:

The size of the array would be very large. You can calculate the amount of memory required by multiplying each subscript together, and then multiplying by the size of each element. The size for this array would be 50 x 500 x 1000 x 4 x 2 bytes = 200,000,000 bytes of memory, or 190.73 megabytes, which would be unacceptable on today's computers.