Array is a data structure that is used to store variables that are of similar data types at contiguous locations. The main advantage of array is random access and cache friendliness. There are mainly 2 types of array.
Single Dimensional and Multidimensional.
Single Dimensional Array.
Multi Dimensional Array:
A multi-dimensional array can be termed as an array of arrays that stores homogeneous data in tabular form. Data in multidimensional arrays is generally stored in row-major order in the memory.
The general form of declaring N-dimensional arrays is shown below.
Syntax:
data_type array_name[size1][size2]….[sizeN];
Examples:
Two dimensional array:
int two_d[10][20];
Three dimensional array:
int three_d[10][20][30];
The total number of elements that can be stored in a multidimensional array can be calculated by multiplying the size of all the dimensions.
For example:
Example:
Click here to submit your answer.
s