Two dimension array

tutorial and example
tutorial and example

C++ Two dimension (2D) Array

Two dimension (2D) array is an array of arrays. It is represented in the form of row and column. The elements of 2D array are accessed through index of row and column.

Declaration of 2D Array

In the above declaration, data_type is C++ data type, array_Name is name of array and size_row is total size of row and size_column is total size of column of array elements.

Initialization of 2D Array

A 2D array is initialized with data type followed by array name and total row size and column size of elements assignment into array.

Another best way to initialize 2D array is as follow:

Access of Array

Elements of array are access through the index (indices) of that element. The index of array starts from[00] and end at [row_size-1column_size-1] of array.

Suppose we want to access the individual element of 2D array, this can be done by passing index of the element in array name.

Two dimension Array example

Two dimension array are accessed by using two loop (nested loop). The external loop access row of array where as inner loop access column of array.