+ 1
only the array identifier represents the base address of an array.why?
only the array identifier represents the base address of an array.why?
1 Answer
+ 1
First of all let us understand what array is?
Array is a extension for most of data types as it allow to store same type of values.
- Array is a subscripted variable
- More or less array has a finite members
- Each item in the array shares the name of the array
- Each item in the array is identified with an unique index
- Random access is possible.
- First index is zero (0) and last index is one less then the length of the array (len-1)
Now moving to your query, array represents finite values stored at contiguous memory location. The address of the first element is stored in the array variable. This address of first element is known as the base address. As ith element is accessed, its address is calculated using a simple mathematics as follows
address of ith element = base address + (I-1) * sizeof(datatype).
Although, array elements are accessed via index, but in background memory address are to be calculated for accessing the said element.