Multidimensional Arrays
The arrays you saw so far were one-dimensional. That is, the store a sequence of values one after the other like a train.
However, arrays may also have two or more dimensions. Such multidimensional arrays are useful for representing data in a tabular form.
Two-Dimensional Array:
To refer to an element in a two-dimensional array, the two dimensions are to be used; the first dimension refers to the row and the second tot the column. The visual shows, how a two dimensional array appears. In this visual, the element in Row-1 Column-1 is A[0][0] which is equal to A(500).
To generate salary report, store the monthly salary figures of five years, the year and the salary figures are to be stored for 12 months in each row. It means 12 values altogether are to be stored in each row for five rows. But, before storing, the compiler should allot space in the memory for 12 x 5 =60 values. This can happen by declaring a two-dimensional array.
Social Plugin