An array is defined as the collection of similar type of data items stored at contiguous memory locations.
Why array is used?
An array is a variable that can store multiple values. For example, if you want to store 100 integers, you can create an array for it. Instead of declaring individual variables, such as number0, number1, …, and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and …, numbers[99] to represent individual variables.
A specific element in an array is accessed by an index.
Arrays have 0 as the first index, not 1.
In this tutorial, you will learn to work with arrays. You will learn to declare, initialize and access elements of an array with the help of examples.
Array is a kind of data structure that can store a fixed-size sequential collection of elements of the same type.
Advantage of C Array
- Code Optimization
- Ease of sorting
- Random Access
- Ease of traversing
- By using loops, you can retrieve the elements of an array easily.
Disadvantage of C Array
- Fixed Size
- Whatever size, you define at the time of declaration of the array, you can’t exceed the limit.
In this section you learned about what array is. In next chapter you will learn to create array in C language.