Single Dimensional Array - C Tutorial

Single Dimensional Array

You can declare a single-dimensional array of five integers as shown in the following example:

  int array[5];

This array contains the elements from array[0] to array[4]

Array Initialization

It is possible to initialize an array upon declaration, in which case, the rank specifier is not needed because it is already supplied by the number of elements in the initialization list. For example:

    int array1[5]={ 1, 3, 5, 7, 9 };
    int array2[]={ 1, 3, 5, 7, 9 };