Array in C
Array in C
It is
a simple and fast way of storing multiple values under a single name. In
this article, we will study the different aspects of array in C language such
as array declaration, definition, initialization, types of arrays, array syntax,
advantages and disadvantages, and many more.
C Array Declaration
In C, we have to declare the array like any other variable before using it.
We can declare an array by specifying its name, the type of its elements,
and the size of its dimensions. When we declare an array in C, the
compiler allocates the memory block of the specified size to the array
name.
Syntax of Array Declaration
data_type array_name [size];
or
data_type array_name [size1] [size2]...[sizeN];
array_name [index];
One thing to note is that the indexing in the array always starts with 0, i.e.,
the first element is at index 0 and the last element is at N – 1 where N is
the number of elements in the array.