Overview of Arryas

Array is a collection of similar data type, these similiar element could be all ints, or all floats, or all chars, etc.

An array is a group of data items of same data type that share a common name.

Ordinary variable are capable of holding only one value at a time. If we want to store more than one value at a time in single variable, we use Arrays.

The compiler reserves 2 bytes of memory for each integer array element.

Array Declaration

Arrays are defined in the same manner as ordinary variable, except that each array name must be accompanied by the size specification.

General form of the array declaration is: -

 Data type array_name[array size];

The compiler will entrap first element as array[0] position. The array element are introduce for 0 to [size-1].

Array Initialization

The array initialization is done as given below

int a [5]={1,2,3,4,5};

 

Example:-

// Program to print the element of Array
#include <stdio.h>
int main()
{
    int i;
    int mark[] ={55,51,53,60};
    for(i=0; i<4; i++);
    {
      display(& mark[i]);
    }
    display(int*n);
    {
       printf("
%d",*n);
    }
}

Output:-

 55
 51
 53
 60