Array is a collection similar data types.An array is stored such that the position of each element can be computed from its index no.By using array, we can access the elements easily.
Less code,Easy to traverse data,Easy to sort data,Random Access are some advantage of array.
array_name[array_size]; //Declaration of Array
int a[5]; char name[5];
Array indexing or initializing
a[0]=1; a[1]=2; a[2]=3; a[3]=4;
Basic example of array-
#include void main() { int i,a[5]={20,30,40,50,60}; for(i=0;i<5;i++) { cout<<"No Is" << [i]; } }
output:
No Is 20
No Is 30
No Is 40
No Is 50
No Is 60