Explanation array data structure and types with diagram
The array is a collection of elements. Elements are of the same type. An array is referred to as the sequential organization that means the data in an array is stored in some sequence.
We are all familiar with the concept of an array. Array gives us a way to order the collection of data of the same type. Array helps the programmer in minimizing the variables.
Suppose you have wanted to arrange the marks of your classmates in ascending order.
Let there are 60 students in your class. To get this goal, you have two options 1) Construct 60 variable and use them to short, the marks in the ascending order. 2) Create an array of 60 items and use them. To access the different marks we have to only change the index. Of course, the second approach is more convenient than the first approach. Now, we will see the concept of an array in C
An array is an important part of almost all programming languages. It provides a powerful feature and can be used as such or can be used to form complex data structure like stacks and queues.
An array can be defined as an infinite collection of homogeneous or same type elements.
This means that an array can store all integers, all floating point numbers, all characters (array of character or strings) or any other complex data type, but all of the same type.
Let’s see some important points to be pointed out about arrays.
These are as follows:
1) An array is always stored in consecutive memory locations. 2) An Arrays can store multiple values which can be referenced by a single name, unlike a simple variable which stored one value at a time followed by an index or subscript, specified inside a sequence bracket. 3) The array name is actually a pointer to the first location of the memory block allocated to the name of the array. 4) An array either be an integer, character or floating data type can be initialized only during declaration time and not afterwards. 5) There is no bound checking concept for arrays in C. it means you can attempt to enter any number of values irrespective of the integer index specified inside square brackets, during the declaration of arrays. It is up to programming to check upper bound or array.
Classification of Arrays
Arrays are divided into two parts 1) One- dimensional Array 2) Multi-dimensional Array 2a) Two dimensional Array 2b) n-dimensional Array