Saturday, May 10, 2008

Multi Dimensional Array

Multi Dimensional Array

Arrays of three or more dimension is called Multi-Dimensional Array.

General form Multi-Dimensional Array:

data_type array_name[s1][s2][s3]......[sn];

Example:
int survey[3][5][12]

Here survey is a 3-dimensionalarray declared to contain
180 integer_type elements.
(3x5x12=180)


Initialization of 4-Dimensional Array:

static int arr [3] [4] [2]={{{2,4}, {7,3}, (3,4}, {5,1}, },
{{3,4}, {3,4}, {3,2}, {4,5}}, {{2,3}, {2,7}, {2,3}, {4,3}}}

In this example, the outer array has three element , each
of which is a two dimensional array of four rows, each other
of which is a one dimensional array of two elements.

An example program to sort an integer array:



Out put of the program :

0 comments:

Copyright

Copyright © 2008 C Tutorial, All rights are reserved