|
CS561-SPRING 2002 TOPIC:CS105-ARRAYS |
|||||||||||||||||||||||||||||||||||
|
Multi
dimensional arrays are used to manipulate data, numeric or otherwise in
the form of matrices, but stored in array locations. Conceptually, they
are matrices, but the method they are stored are typical of array
elements and are viewed as such too. The following declaration example
illustrates a typical two dimensional array for a simple C++ program, Example
:: int TWO_DIM [5][7]; The above declaration now creates a two dimensional array named as TWO_DIM having 5 rows and 7 columns and that holds integer elements only and would be perceived as being laid out in the manner illustrated in the diagram below,
Data
elements are simply accessed by specifying their location in the array,
for example TWO_DIM[2][4]
= 10;
would assign the element in the third row and fifth column an
integer value of 10.
|