Saturday, 13 July 2019

What is array?

Arrays a type of data structure that can store a fixed-size sequential collection of elements of the same type.
We can't take any array with a half of data types.
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.

The bracket [  ] denotes to the compiler that for an array.

The declaration of array -

Data_type <array name>[expression]
Ex-
         Int array[10]

Intialization of array
 
Int array[10]={1,5,8,9,6,0,3,4,2,7}

Types of array -

Arrays are important to C and should need a lot more attention. The following important concepts related to array should be clear to a C programmes.

 

Multidimensional arrays

C supports multidimensional arrays. The simplest form of the multidimensional array is the two-dimensional array.

Twodimensional array

The simplest form of multidimensional array is the two-dimensional array. A two-dimensional array is, in essence, a list of one-dimensional arrays. To declare a two-dimensional integer array of size [x][y], you would write something as follows:

type arrayName [ x ][ y ];


 

Where type can be any valid C data type and arrayName will be a valid C identifier. A two-dimensional array can be considered as a table which will have x number of rows and y number of columns.

No comments:

Post a Comment