Multidimensional Arrays everything you want to know in C Programming

Multidimensional arrays are arrays with more than one dimension, that is columns. One dimensional array will have only one row and many columns but the multidimensional arrays will have more than one row and more than one column.

Introduction :

                    Multidimensional arrays are arrays with more than one dimension, that is columns. One dimensional array will have only one row and many columns but the multidimensional arrays will have more than one row and more than one column. Learn about Arrays here.

Two-dimensional arrays:

                            Two-dimensional arrays have two rows and two columns meaning that they will have two indices in memory. The two-dimensional arrays are the most common implementation of the two-dimensional arrays. If the rows can be represented as R and columns can be represented as C. The array might look like A[R][C]. The index rules stay the same for the multidimensional arrays as well, they start from 0 and go up to n.

Implementation of two-dimensional arrays:

                                     A two-dimensional array with 10 rows and 10 columns can be represented as A[10][10].

Syntax for decleration:

data_type array_id [number of rows][number of columns];

Eg :

int a[4][4];

Assignment:

a[4][4]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};

Structure in the memory:

Accessing the array:

a[r][c] will give you the value present in the cell. For example, a[0][0] will give you the value in the first cell that is 1.

Let us see an example of c program to declare and assign a two dimensional array.
#include <stdio.h>
void main()
{
int a[2][2]={1,2,3,4};
a[0][0]=0;
}

Two-dimensional arrays applications :

Two-dimensional arrays are used as a list in database applications. 2D arrays can also be used to save the matrix forms. As the matrix also follows the same format of rows and columns. Although the number of rows and columns might change, the format doesn’t. Then the 2D arrays can be used for table-like structures to create an effective virtual database environment across the program.

Repetition of code :

This can also be used to avoid any repetition of code. The arrays are the golden start for anyone considering to be a serious programmer as they involve active calculations and some active mathematical calculations. Both of the qualities are considered to be the golden assets for any programmer. C programs consist of the arrays and their applications a lot even in the background in the forms of stacks.

Conclusion :

Arrays are one of the most important ways of storing data in C programming and a Multidimensional array makes the job lot easier and harder depending on your aptitude skills. You can read more articles and tutorials on C programming on our website here.

References :

https://www.geeksforgeeks.org/multidimensional-arrays-c-cpp/
https://www.tutorialspoint.com/cprogramming/c_multi_dimensional_arrays.htm
https://www.programiz.com/c-programming/c-multi-dimensional-arrays

Default image
Karan
I'm Karan Dharmalingam, Co-founder of Criss Cross Tamizh. My responsibilities in Criss Cross Tamizh include Head Content Writer and Editor, Video Producer, and Editor. I have always believed that my best work is in the content creation field. The journey of CCT was almost like a bar joke. While talking to my bestie Arun Kumar, he jokingly said how cool it would be if we can have our own websites and YouTube channels. And I also felt the same and right at that moment we started a YouTube channel and it's almost 2 years and we have come a very long way both in business and as humans as well. Thanks for reading nanba/nanbi !!
Articles: 4

Leave a Reply