Multi Dimensional Array in C++

Initialized by specifying bracketed values for each row. This is an array with 2 rows and 3 columns.

Source code :

#include <iostream>
using namespace std;

int main()
{
    int x[2][3] = 
    
    {
        {2, 3, 4}, 
    //Row 1
        {8, 9, 10}
    //Row 2    
    };
    
    cout << x[0][2] << endl;

    return 0;
}

Output :

4

Notes :

The first index 0 refers to the first row and the second index 2 refers to the 3rd element of the first row, which is 4.


Output :


                

Comments :