What is an Array
An Array can be define infinite collection of homogeneous (similar type) elements this means that an array can store either all integer, all floating point all character on any other complex data type but all of same data type.
Some important points to be pointed out about array there are as follows -
1. An array elements are always stored in sequential memory locations.
2. An array can store multiple value which can be reference by a single name unlike a simple variable which store one value at a time. followed while an index for subscript specified inside a square.
3. An array name is actually a pointer to the first location of the memory block allocated to the name of the array.
4. There is no bound checking concept for array in C language. It means then one can attempt to enter any number of value irrespective of the integer index specified inside square bracket during declaration of array.
Arrays can of following types :
1. One dimensional (1-D) arrays or Linear arrays
2. Multi dimensional arrays
(a) Two dimensional (2-D) arrays or Matrix arrays
(b) Three dimensional arrays
Arrays can of following types :
1. One dimensional (1-D) arrays or Linear arrays
2. Multi dimensional arrays
(a) Two dimensional (2-D) arrays or Matrix arrays
(b) Three dimensional arrays
One Dimensional Array
A one dimensional array is one in which one subscript specification is needed only to specify a particular element of the array.
One dimensional array can be declare as follows-
One dimensional array can be declare as follows-
Data type variable name [expression] .
The Size of array can be determine as follows size - [(upper bound - lower bound) + 1]
Initialization of One-dimensional array -
ANSIC allow automatic array variable initialize in deceleration by constant initializer as we have seen scaler variable. These initializing expression must be constant (known of compile time) value. Expression with identifier or function calls may not be use in the initializer.
Here are some declaration with constant initializer.
int a[10]={10, 11, 13, 14};
Initialization of One-dimensional array -
ANSIC allow automatic array variable initialize in deceleration by constant initializer as we have seen scaler variable. These initializing expression must be constant (known of compile time) value. Expression with identifier or function calls may not be use in the initializer.
Here are some declaration with constant initializer.
int a[10]={10, 11, 13, 14};
char word[10]={e, i, o};
Comments
Post a Comment