Array
An array is a collection of variables of same type that are represented by a common name i.e. array is the collection of homogenous data type (Contains similar datas). If we declare array as int then it must only contain all integer data and same for floats and char. Each array element is specified by array name followed by index or subscript enclosed in square bracket (eg, a[10]). Hence, it is also called indexed or subscripted variables. In an array index of array represent the size of an array.
Let us consider, int age[5]
This mean array name is age which is capable of storing 5 different data under integer datatype.
age[0] = 15
age[1] = 25
age[2] = 13
age[3] = 22
age[4] = 17
Types of array
Depending upon the number of subscript or index number array are of 2 types:
1-Dimension:
This type of array has only one subscript.
Declaration:
Data_type array_name[size]
Example:
int salary[100]
Program example.