Representation Of Arrays.

An array is a collection of variables of the same type that are referred to through a common name. An index accesses a specific element in an array. The lowest address corresponds to the first element, and the highest address to the last element. Arrays can have one to several dimensions. The most common array is the string, which is simply an array of characters terminated by a null.
The size and the data type of an array cannot be changed after the declaration. The array’s length is defined when the array is created, and the array’s length is fixed. Therefore, it cannot be changed.
In arrays, each value is an element and these elements are accessed through an index.

Single Dimensional Array:
The single-dimensional array is also known as a one-dimensional array with a group of elements having the same data type and the same name.
single dimension array is :
datatype var_name[size];
Example :

int “a” [3]
where int: data type  
      a: array name      
3: expression

Index Data
a[0] 34
a[1] 56
a[2] 4532

Multi Dimensional Array :
The multi-dimensional array is that array in which data is arranged in the form of an array of arrays. The multi-dimensional array can have as many dimensions as required.
So, two-dimensional and three-dimensional arrays are commonly used.
Multi dimension array is :
datatype array_name [a1][a2][a3]…[an];
Example :
int x[10][20]; [or]
x[0][0] :0
x[0][1] :1
x[1][1] :2 [or]
x[0][0][0] :4
x[0][0][1] :5
x[0][1][0] :6
In similar ways, we can create arrays with any number of dimensions. However, the complexity also increases as the number of dimensions increases.

Advantages of arrays:
1) Accessing an element is very easy by using the index number.
2) User wishes to store multiple values of a similar type, then the Array can be used and utilized efficiently.
3) Search process is applied to an array easily.

Disadvantages of Arrays:
1) Insertion and deletion are quite difficult in an array
2) Number of elements to be stored in an array should be known in advance.
3) Allocating more memory than the requirement leads to a wastage of memory space.

Maroju Sanjana

Categories: News