Introduction to Array in C language.
“Life is like riding a bicycle. To keep your balance , you must keep moving”
A warm welcome to all!!
Today we are going to discuss very important and interesting topic of C language i.e Array.
Soo let’s start quickly 🙂
Definition of Arrays:-
1)Array is a collection of elements of similar data type.
2)That is we can make a collection of all same data types ie:- int, float, char etc.
3)Arrays represent multiple data items of the same type using a single name.
4)In arrays, the elements can be accessed randomly by using the index number.
5)Arrays allocate memory in contiguous memory locations for all its elements. Hence there is no chance of extra memory being allocated in case of arrays. This avoids memory overflow or shortage of memory in arrays.
Applications of Arrays:-
1) Array stores data elements of the same data type.
2) Maintains multiple variable names using a single name. Arrays help to maintain large data under a single variable name. This avoid the confusion of using multiple variables.
3) Arrays can be used for sorting data elements. Different sorting techniques like Bubble sort, Insertion sort, Selection sort etc use arrays to store and sort elements easily.
4) Arrays can be used for performing matrix operations. Many databases, small and large, consist of one-dimensional and two dimensional arrays whose elements are records.
Types of Arrays:-
There are mainly two types of array, they are as follows.
1)One dimensional array
Let’s discuss one by one…
1) One dimensional array:-
A one-dimensional array is also called a single dimensional array where the elements will be accessed in sequential order. This type of array will be accessed by the subscript of either a column or row index.
Syntax of declaring One-dimensional Array:-
Eg:- int num;
This declaration represents an array named a containing 5 elements.
2) Two Dimensional array:-
When the number of dimensions specified is two then it is called as a two dimensional array.
Syntax of two dimensional array :-
Data type arrayname[size][size];
Soo this is a small introduction of array in C language.
We will see array in detail in the upcoming articles!!
Soo meet you all in the next article.
Thank you all for your support….. Keep supporting 🙂
Have a wonderful day ahead 🙂
You must log in to post a comment.