- Array is a
collection of variables of same type known by a one name.
- The
individual elements of an array are referred by their index or subscript value.
- Arrays can
be divided into two categories.
1.
One Dimensional Array
2.
Multi Dimensional Array
1. One Dimensional Array
- The syntax
for declaring a one dimensional array is:
- Here,
DataType defines the type of array elements. It can be int, char, long int etc.
- ArrayName
is the name of a variable which represents the array.
- Size represents
the size of array which is represented within [] symbols.
For
Example:
int a[10];
here, int
is DataType, a is the name of an array and 10 is the size of an array.It
defines 10 integer values, all known by variable name a.
In c
language, array index or subscript starts from 0. So, for above example, we
have 10 different integer variables as a[0], a[1]…a[9], where a[0] is the first
element and a[9] is the last element of array.
No comments:
Post a Comment