C Array Declaration

Array Declaration

Like any other variable, arrays must be declared before they are used. General form of array declaration is,

Syntax:

data-type variable-name[size];

Example:

int arr[10];

Here int is the data type, arr is the name of the array and 10 is the size of array.
It means array arr can only contain 10 elements of int type.
Index of an array starts from 0 to size-1 For Example, first element of arr array will be stored at arr[0] address and last element will occupy arr[9].
Graphical representation of above example is given below
array declaration in c



Share This Page on:


Ask Question