3. What is an array ?
✘ Array is a collection of similar data items are
stored under a common name.
✘ It is a continuous memory location.
✘ The lowest address corresponds to the first
element and largest address to the last element.
✘ Example:
a[3]={1,2,3}
3
4. Classification of arrays:
Depending upon the number of subscripts used,
arrays are classified into three types
1. One-dimensional array
2. Two- dimensional array
3. Multi – dimensional array
4
6. Initialization:
An array can be initialized at
I. compile time
II. run time
✘ After declaration ,the array elements must be
initialized otherwise they hold garbage value.
6
7. 1.Compile time initialization:
Initialization at the time of the declaration is known as compile time
initialization.
Syntax:
data_typevariable_name[dimensional/size of an array]={value1, value2,…value n};
Example:
• int a[5]={1,2,3,4,5};
• int b[]={1,2,3,4,5};
• char name[]={‘A’,’B’,’C’};
7
8. 2. Run time initialization:
When the array have large number of elements then the
array elements can be initialize at run time.
Syntax:
scanf(“format specifier”, &variablename[size] );
8