Two-Dimensional Arrays
The simplest form of the multidimensional array is the
two-dimensional array. A two-dimensional array is,
in essence, a list of one-dimensional arrays.
To declare a two-dimensional integer array of
size x,y, you would write something as follows:
type arrayName [ x ][ y ];
Where type can be any valid C++ data type and
arrayName will be a valid C++ identifier.
A two-dimensional array can be think as a table,
which will have x number of rows and y number of columns.
A 2-dimensional array a, which contains three rows and
four columns can be shown as below:
Thus, every element in array a is identified by an element
name of the form a[ i ][ j ], where a is the name of the
array, and i and j are the subscripts that uniquely identify
each element in a.
No comments:
Post a Comment