• admin@embedclogic.com

Types of Array

There are two types of array categories in C language –

— One-dimensional Array

— Multi-dimensional Array

One- dimensional Array

One dimensional array is also known as a linear array. it has only one row with multiple columns.


dataType array_variable_name[MAXIMUM_COLUMN_COUNT];


Above array is a one-dimensional array because it has only one row but 5 columns. I have already mentioned the one-dimensional array in Array Introduction.

Multi-Dimensional Array

However, C allows many dimensional arrays like 2-D,3-D,4-D……n-D as per the compiler support but here I am explaining only 2 types of Multi-dimensional array.

— Two-Dimensional Array

— Three-Dimensional Array

Two- dimensional Array

A two-dimensional array is an array of one-dimensional array.

Two-dimensional array expands along both direction (x and y) i.e it has multiple row and columns.


dataType array_variable_name[ROW_COUNT][COLUMN_COUNT];


dataType array_variable_name[ ][COLUMN_COUNT];

In the second Syntax if we know the column count in one row then we can calculate row count but vice-versa is not possible.

like if COLUMN_COUNT=5 and  total element Count=20 then


2-D Matrix/Array representation

For E.g We can access element of 1st row and 0th column like this –

2-D Matrix/Array Memory Diagram
2-D Matrix-Program

Write a program to display n x m matrix where n is the row and m is the column of the matrix.  a user will enter the desired number of row and column at runtime.

Suppose user enters n=2 and m=3 then matrix must represent like this – where Matrix[n][m]= any user input


Three-dimensional Array

A three-dimensional array is an array of two-dimensional array.

A three-dimensional array has 2-dimensional blocks in all 3 directions(x, y, z).


dataType array_variable_name[2D_Block_Count][ROW_COUNT][COLUMN_COUNT];

2D_Block_Count: Total number of 2D array Count

ROW_COUNT: Row count in each block of 2D array

COLUMN_COUNT: Column Count in each block of 2D array


In above example-

2D_Block_Count: 2



In above example, you can see that there are two sets of the two-dimensional array.

Pictorial representation of 3-D array memory Map

We can access elements at any index of 3-D array like this –

3-D Matrix Program

Write a program to display b x n x m 3-D matrix where b is the 2-d block count, n is the row and m is the column of each 2-d matrix.  a user will enter the desired number of blocks, row, and column at runtime.


So here I have tried to cover all of the basics of the one-dimensional and multi-dimensional array and I will discuss the use of pointers and function in the array in upcoming chapters .you must see the example section to get your concepts more clear.