C Programming

Multidimensional Arrays

Posted on 17th February 2014

Multidimensional array has elements along various dimensions. The elements of a multidimensional array are accessed using multiple indexes. For example a two dimensional array has elements in rows and columns as shown below:


multiarray=
 
200300500
130230320
800150600
 

Two indexes are required to access the elements of this array.
multiarray[1][1] is the element in the 1st row and 1st column which is 200
multiarray[1][2] is the element in the 1st row and 2nd column which is 300
multiarray[1][3] is the element in the 1st row and 3rd column which is 500
multiarray[2][1] is the element in the 2nd row and 1st column which is 130
multiarray[2][2] is the element in the 2nd row and 2nd column which is 230
and so on....

A multidimensional array is declared using the syntax

variabletype arrayname[dimension-1-limit][dimension-2-limit]....[dimension-n-limit];

multiarray in the above example is declared as:

mutiarray[3][3];

Post a comment

Comments

Nothing yet..be the first to share wisdom.