Wednesday, 18 November 2015

Array


 Array is a collection of same type of variables having equal size of memories. All the elements of array are allocated continuously starting from an address the first element address of an array is called base address or base element address.
Array can have data items of simple types int, float , character.

Declaration of an array .
Data type ,Array name [no. of elements]
Ex.   int  a[5]
float a[5]
char S1[10]



Array is a collection of homogeneous elements.Structure is a collection of heterogeneous elements.

Types of arrays:-

1 Single dimensional arrays:- the simplest form of an array is a  single dimensional array. The array is given a name and its element are referred to buy there subscript or indius . C++ arrays index numbering starts with o. Its elements are stored in contiguous memory location in their index order.

2 Two dimensional (2-d) arrays - A two dimensional array is an array in which each element is itself an array . The no. of elements in a 2-d array can be determined by multiplying no. of rows with no. of columns.The two dimensional array is an array having single dimension array as its element. The general form of a two dimensional array declaration in C++ is as follows:-
type array name [rows] [columns];
Here type is the base data type,array name is the name of array, the first index refers to the no. of rows in the array and the second index refers to the no. of columns in the array.2-D array are processed using nested loops.

3 Multidimensional array :-  Multidimensional arrays are arrays with dimensions more than two.the general form of multidimensional array declaration
type name [a] [b] [c].........[z];
The array of there or more dimensions are not often used because of there huge memory requirements and the complexity involved with there manipulation of multidimensional arrays takes more time compared to single dimensional and two dimensional arrays.


No comments:

Post a Comment