An array is a collection of items stored at contiguous memory locations. The array is used to store multiple data of the same type together.
Array is a linear data structure. The elements are stored at contiguous memory locations in an array.
An array contains elements of homogeneous data type or similar data type and
size of array is fixed i.e, it cannot be increased or decreased once
declared.
But there is an exception, in some languages like Python, JavaScript etc.
elements of different data type can be stored and size can be modified.
But this rule of similar data type and fixed size of the array holds strictly
for languages like C, C++ and Java etc.
In most of the programming language index of the array starts from 0 that's why it is known as zero-based indexing. But some languages follow different conventions for indexing of an array.
An array is represented in various ways in different languages. Following are the main things used to declare an array.
# var_name = []
arr1 = [] # empty array
arr = [1, 2, 3, 4, 5] # array with elements
// data_type var_name[size];
int arr1[5]; // empty array
int arr2[5] = {1, 2, 3, 4, 5} // array with elements
// data_type var_name[size];
int arr1[5]; // empty array
int arr2[5] = {1, 2, 3, 4, 5} // array with elements
// let var_name = []
let arr1 = [] // empty array
let arr2 = [1, 2, 3, 4, 5] // array with elements
AUTHOR