What is Array?


An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array).




Properties of array


There are some of the properties of an array that are listed as follows -


Each element in an array is of the same data type and carries the same size that is 4 bytes.



Elements in the array are stored at contiguous memory locations from which the first element is stored at the smallest memory location.



Elements of the array can be randomly accessed since we can calculate the address of each element of the array with the given base address and the size of the data element.




Representation of an array .

We can represent an array in various ways in different programming languages. As an illustration, let's see the declaration of array in C language -


Index starts with 0.


The array's length is 10, which means we can store 10 elements.


Each element in the array can be accessed via its index.