Arrays

ARRAYS

Array is a collection of similar data type, that occupy same space in memory, all the data storage location should have same data type. 
An Array can be One dimensional or Multidimensional. One dimensional array is a series of data item, it is a type of linear array.

Declaration Of Array 

An array is declared by writing its data type which tells the compiler that all the elements of array are of this (int, char, double etc) particular data type. After that name is assigned to an array and in the square brackets a constant or variable is used which is index or subscript or array size. It tells the compiler that how many items can be stored in an array.
int name[subscript];
int sum[10]; 

Above array can hold 10 items. The index of array always starts from 0. In above example the index will start from 0 and end at 9.

 Initialization Of  An Array

 Array can be initialized while writing the program code. It can initialized as under:

int sum[10]={1,5,6,7,3,4,8,2,9,0}
1 will be assigned to sum[0]
5 will be assigned to sum[1]
6 will be assigned to sum[2]
.
.
.
0 will be assigned to sum[10]

Accessing Array Elements

The particular item of an array can be accessed through its index number. It can be accessed as:

 cout<<sum[5];

 the output will be 4 which is present at location 5 of an array 
sum[10]={1,5,6,7,3,4,8,2,9,0} 

Note: Always Start counting from 0 in case of arrays.