Multi-dimensional Array

 A list of items can be given one variable name using more than two subscripts and such a variable is called multi-dimensional array.

Three dimensional Array
  A list of items can be given one variable name using three subscripts and such a variable is called three dimensional array.
Declaration of Three Dimensional Array:-
Syntax:-

 Datatype  array_name[size of two dim array][nr][nc];

nr-->no.of rows
nc-->no.of columns
>>The data type specifies the type of elements that will be contained in array such as int float or char.
  Initialising three dimensional array: 
>>Like the one dimensional array three dimensional array may be initialised by  following their declaration with list of initial values enclosed in braces . 
int table[2][2][3]={0,0,0,1,1,1,6,6,6,7,7,7};

>>This initializes the elements of first two dimensional (Matrix )First row zeros and the second row to own once and second Matrix elements are First row to sixs the second matrix to sevens.
>>This initalization is done row by row.
 >>The above statement can be e equivalently written as 

int table[2][3]={0,0,0},{1,1,1},{0,0,0},{1,1,1}};

we can also initialize a two dimensional array in the form of a matrix are shown .
 int table[2][3]={
{
{0,0,0},
{1,1,1}
},
{
{6,6,6}
{7,7,7}
}
};

Comments

Popular posts from this blog

History of C language

Lab programs of C

Algorithm Pseudopods Flow-chat