What is a Two-Dimensional Array?
How To Declare a Two-Dimensional Array?
syntax: data_type name_of_array[size1][size2]...[sizeN];
For example:int arr[4][5] //Two Dimensional Arraysize of arr[4][5] = 4x5 = 20 elements we can store in this array
int arr[4][5][6] //Three Dimensional Arraysize of arr[4][5][6] = 4x5x6 = 120 elements we can store in this arrayHow To Initialize a Two-Dimensional Array?
int arr[4][5] = {{3, 4, 6, 9, 5}, {1, 2, 3, 5, 8}, {7, 0, 1, 3, 5}, {2, 4, 9, 0, 3}};How To Traverse Two-Dimensional Array?
//C++ program to traverse 2D Array #include<iostream> using namespace std; int main(){ int arr[4][5] = {{2, 3, 5, 6, 8}, {1, 2, 4, 8, 3}, {0, 4, 2, 9, 1}, {5, 4, 3, 2, 1}}; cout<<"Displaying 2D Array: "<<endl; for(int i = 0; i < 4; i++){ for(int j = 0; j < 5; j++){ cout<<arr[i][j]<<" "; } cout<<endl; } return 0; }
Displaying 2D Array:
2 3 5 6 8
1 2 4 8 3
0 4 2 9 1
5 4 3 2 1















Trends is an amazing magazine Blogger theme that is easy to customize and change to fit your needs.