The Array is a contiguous data structure. It enables you to store data in contiguous form.
It is an indexed collection of a fixed number of homogenous type data.
Let’s assume, you want to store 5 numbers of colors in variables. Instead of storing them in each variable, you can store all the colors in an array. An array can be used anywhere, you want to store a similar type of data in a single variable.
The array is highly used when doing sorting and search operations.
For example –
Let’s understand another example, writing a function that will return all divisors of a number.