# 2d arrays in C++

Article by: Manish Methani

Last Updated: October 19, 2021 at 10:04am IST

## C++ Multi-Dimensional Arrays

MultiDimensions word itself says there will be an array with mutiple dimensions(rows and columns). The simplest form of multiple Dimensions is "Two Dimensional Array".

## Syntax :-

```datatype arrayName[rows][coulmns];
```

## Examples of Multi-Dimensional arrays

```/* Two Dimensional Array */
int val = a[2][3];

/* Three Dimensional Array */
int val = a[2][3][4];

Here,
a[2][3] = 2 rows , 3 columns.
a[2][3][4] = 2 rows in outer array. Inside it 3 rows, 4 columns.
```

## Program

```#include >
using namespace std;

int main () {
// an array with 3 rows and 2 columns.
int a[3][2] = { {0,0}, {1,2}, {2,4}};

// output each array element's value.
for ( int i = 0; i < 3; i++ )
for ( int j = 0; j < 2; j++ ) {
cout << "a[" << i << "][" << j << "]: ";
cout << a[i][j]<< endl;
}

return 0;
}```

## Output :-

```a[0][0]: 0
a[0][1]: 0
a[1][0]: 1
a[1][1]: 2
a[2][0]: 2
a[2][1]: 4
```

## Simplified Coding for Beginners.

Mobile App Development, Web App Development, Programming Languages, Latest Tech News & lot more.

## The Complete Angular Course

Instructor: Manish Methani

Free

## C Programming for Absolute Beginners

Instructor: Manish Methani

## Flutter Mobile App Development Course

Instructor: Manish Methani

Free

## Learn HTML, CSS & Bootstrap

Instructor: Manish Methani

## C Programming Test

Test your C Programming skills with this comprehensive mock test on C Programming.

## Flutter Test

Solve most asked Interview Questions on Flutter and Test your foundational skills in flutter.

## GATE(CSE) Operating Systems

Solve most asked GATE Questions in Operating Systems and test your Gate Score.

## HTML,CSS Test

This is a mock test designed to help you assess your knowledge and skills in HTML and CSS.

## (GATE CSE) Data Structures & Algorithms Test

Solve most asked GATE Questions in Data Structures and Algorithms and test your Gate Score.

include_once 'codzify-footer.php'; ?>