Showing posts with label Array. Show all posts
Showing posts with label Array. Show all posts

Saturday, May 10, 2008

Size of operator

Size of operator

The size of operator returns a number of bytes the
operand occupies in memory. The operand may be a variable,
a constant or a data type qualifier. It is a
compile time operator.

An example of size of



Output of size of operator:




The output of the above program is 2 because int occupies two byte in memory.

The size of operator is generally used to determine the
length of entities called arrays and
structures
when their size is not known to the programmer.




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 :

Copyright

Copyright © 2008 C Tutorial, All rights are reserved