Thursday, April 5, 2018

Explain of Array types


Dimension Explain of Array :-


Array can be divided into the following categories based on the dimension.
1.     One dimensional array.
2.     Two dimensional array.
3.     Multi-dimensional array.
One Dimensional Array :
  Array is a dimensional array balloon made with a single user.

Its structure :
data_type array_name[ size ];
Example :
int i[ 10 ];
float a[ 10 ];
char ch[ 20 ];
double b[ 5 ];

Two Dimensional Array :

  Array is a dimensional array balloon made with a two user.
          Its structure :
                    data_type array_name[ row_size ][ col_size ];
          Example :
                    int student[ 3 ][ 4 ]; 
60
[ 0 ][ 0 ]
80
[ 0 ][ 1 ]
75
[ 0 ][ 2 ]
62
[ 0 ][ 3 ]

40
[ 1 ][ 0 ]
90
[ 1 ][ 1 ]
82
[ 1 ][ 2 ]
34
[ 1 ][ 3 ]





25
[ 2 ][ 0 ]
10
[ 2 ][ 1 ]
35
[ 2 ][ 2 ]
42
[ 2 ][ 3 ]





Multi-dimensional Array :

  Array is a dimensional array balloon made with a three or more than user.
          Its structure :
                    Data_type array_name[ s1 ][ s2 ]….[ sn ];
          Example :
                    int s[ 2 ][ 3 ][ 4 ];
                    float table[ 5 ][ 6 ][ 4 ][ 5 ];


Initialization :


One Dimensional Array :
Static data_type array_name[ size ] = { list of values };
Example : static int number[ 3 ] = { 5, 0, 7 };

Two Dimensional Array :


There are same type of one dimensional array;
Example : static int table[ 2 ][ 3 ] = { 1, 2, 3, 4, 5, 6 };
Example of Matrix: static int table[ 2 ][ 3 ] = {{ 1, 2, 3}, {4, 5, 6} };


Share:

0 comments:

Post a Comment

Blogger templates