Multidimensional Arrays
In this lesson, we'll be learning about static multidimensional arrays and dynamic multidimensional arrays.
We'll cover the following
In this lesson, we will move towards the advanced concepts of arrays, i.e, multidimensional arrays. A two–dimensional array is the simplest form of a multidimensional array. We can see a two–dimensional array as an array of the one-dimensional array for easier understanding.
Initialization of two-dimensional array
In C++, arrays can be declared as static and dynamic. A generic definition of initialization is given below:
Static two-dimensional array declaration:
data_type arr[x][y];
Dynamic two-dimensional array declaration:
datatype ** arr = new datatype *[rowSize];
for(int i=0; i<rowSize; i++)
arr[i] = new datatype[colSize];
Data types could be int, float, double and char.
Consider the example below:
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.