Saturday 31 August 2013

MULTI – DIMENSIONAL ARRAY | C Programming Language Tutorial pdf



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 Arrays :
Syntax:
<datatype> <array_name>[sizeofno.oftwoDimArray] [sizeofrow] [sizeofcolom];
=> The datatype specifies the type of elements that will be contained in the array, such as int, float, or char.

Initializing Three- Dimensional Arrays:
=> Like the one-dimensional arrays, three-dimensional arrays may be initialized by following their declaration with a 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 to zero's and the second row to one?s and second matrix elements are first row to six?s and the second row to seven?s.
=> This initialization is done row by row.
=> The above statement can be 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 as shown.
int table[2][3] = {
{
{0,0,0},
{1,1,1}
},
{
{6,6,6},
{7,7,7}
}
} ;

0 comments:

Post a Comment

 

C Programming Language Interview Questions and Answers Tutorial for beginners. Copyright 2013 All Rights Reserved