Arrays are the most basic data structures used in programming. Arrays are data structures that contain a group of elements. Typically these elements are all of the same data type, such as char
or int
.
All arrays consist of contiguous memory locations. We can access the elements with their index. The lowest address corresponds to the first element and the highest address to the last element.
Array Declaration
type arrayName [ arraySize ];
type
is the datatype of the array elements
Array Initialization
int array1[] = {1,2,3};
Accessing Elements of Array
int variable1 = array[0];