

One to traverse the rows and another to traverse columns. To output all the elements of a Two-Dimensional array we can use nested for loops. Therefore, for row index 2 row number is 2+1 = 3. Note: In arrays, if the size of an array is N. The above example represents the element present in the third row and second column. In the above example, there is a total of three rows so there are three sets of inner braces.Īccessing Elements of Two-Dimensional Arrays: Elements in Two-Dimensional arrays are accessed using the row indexes and column indexes. Each set of inner braces represents one row. This type of initialization makes use of nested braces. Initializing Two – Dimensional Arrays: There are two ways in which a Two-Dimensional array can be initialized. A two – dimensional array ‘x’ with 3 rows and 3 columns is shown below:

The total number of elements that can be stored in a multidimensional array can be calculated by multiplying the size of all the dimensions.

