9.1 Definition

An array can be defined in many ways.

int x[5];

This defines an array called x of 5 integers. An individual element can be accessed as x[2]. Of course, the ``2'' can be replaced by any integer expression.

int x[5][6];

This defines a two-dimentional array x of 5 times 5 (25) integers. To address one element, you can use something similar to x[1][2]. However, you can also refer to an entire row by saying x[1]. x[1] is essentially an array of 6 elements. Of course, you can substitute ``1'' and ``2'' by any integer expression.

There is no language limitation to the number of dimensions of an array.



Copyright © 2006-09-25 by Tak Auyeung