C Arrays


  • Arrays
  • Declaration of arrays
  • Initialization of arrays
  • Multi dimensional Arrays
  • Elements of multi dimension arrays
  • Initialization of multidimensional arrays


The C language provides a capability that enables the user to define a set of ordered data items known as an array.
In C we can define variable called grades, which represents not a single value of grade but a entire set of grades. Each element of the set can then be referenced by means of a number called as index number or subscript.

Declaration of arrays

Like any other variable arrays must be declared before they are used. The general form of declaration is:

type variable-name[50];
The type specifies the type of the elements that will be contained in the array, such as int float or char and the size indicates the maximum number of elements that can be stored inside the array for ex:

float height[50];
Declares the height to be an array containing 50 real elements. Any subscripts 0 to 49 are valid. In C the array elements index or subscript begins with number zero.
So height [0] refers to the first element of the array. (For this reason, it is easier to think of it as referring to element number zero, rather than as referring to the first element).

Initialization of arrays

We can initialize the elements in the array in the same way as the ordinary variables when they are declared. The general form of initialization off arrays is:

type array_name[size]={list of values};
The values in the list care separated by commas,

for example the statement 
int number[3]={0,0,0};
Will declare the array size as a array of size 3 and will assign zero to each element if the number of values in the list is less than the number of elements, then only that many elements are initialized. The remaining elements will be set to zero automatically.

Array program

#include <stdio.h> 
#include <stdlib.h> 
Int a[3],i; 
printf(" enter array elements”); 
	printf(“output is :%d”,a[i]);

Make Comments..!!

Riya Shah
example though better understand this concept..good
Like · Comment ·
Brahmi Reddy
Like · Comment ·
Jatinkumar Patel
very nice.............Dear.............
Like ·
Download Android App