3 Dimensional Arrays in C

For Complete YouTube Video: Click Here

We will try to understand 3 Dimensional Arrays in C in this class.

Our previous classes clearly explained the concepts of one-dimensional and two-dimensional arrays.

3 Dimensional Arrays in C

The image below shows the way the 3-dimensional arrays are declared in C.

3 Dimensional Arrays in C
3 Dimensional Arrays

Visualizing a 3 Dimensional array

For example, if we consider our first declaration, it states that it has three columns of two-dimensional arrays, and each two-dimensional array has three rows and three columns.

The number of elements in the above array is 3*3*3 = 27.

For example, assume that our first array has elements from 1 to 27.

The visualization of the 3-dimensional array is shown below.

3 Dimensional Arrays in C 1
3 Dimensional Arrays

Accessing the elements of the 3-dimensional arrays

All the elements are stored linearly on memory.

If we want to access six, then the declaration should be a[0] [1] [2].

The above declaration means that in the zero blocks of the 2-dimensional arrays, access the element in the first row and second column.