à
Array
is a memory variable, which can store multiple values in it.
à
à
Array
is a collection of values of similar data type.
à
An
array can be declared as follows
àDataType ArrayName[n]; n - number of
elements
à
à eg
: int a[5];
à float
salary[500];
à char
name[15];
à
Array
elements can be accessed by mentioning the corresponding index position.
à
à
Index
for any array, starts from 0 and ends with n-1.For example,
à int
a[5];
à Then
the five array elements can be refered as
à a[0],a[1],a[2],a[3]
and a[4].
à
à
At the
time of declaration of an array, we can initialize the array as follows
DataType ArrayName[n] = {values,....};
à
à
In
this case, there is no need of mentioning number of elements of array i.e. n.
à
à
If you
don't initialize, array elements will have garbage values. For handling array
elements, we can frame loops.
à Arrays
are of two types
§ Numerical Array.
§ Character Array.
No comments: