What is Array in C?

Array, a data structure in C. See in details about it in this article.
Array:
Array is a contiguous data structure in C, yet simplest form of data structure in C. That means, it stores all the variables in a linear manner, one after another. When you declare a variable, it is stored in memory at random memory location, but if you want to group the variables together, you have to use array.
Array is a collection of elements of same datatypes.
If you declare variables like this:
int marks1,marks2,marks3;
It is advisable to use array and declare them like this:
int marks[3];
It will make 3 variables of marks i.e. mark[0],mark[1],mark[2]. Remember that in C indexing starts with 0. That means, first element will be 0, second will be 1 and so on.
You can declare and assign value to array elements in many ways.
int a[3];
a[0]=50;
a[1]=60;
a[2]=58;
Or
int a[3]={50,60,58};
The elements of array share memory location together, that you can see in this table below.

Values506058
Variable(int)a[0]a[1]a[2]
Memory Location101974-101975101976-101977101978-101979

Related Posts with What is Array in C?