Mask-group

Arrays in C



  • Array is a collection or group of elements(data).

  • All the elements of the C array are homogeneous(same data type).

  • It has a contiguous memory location.

Advantages of using Arrays:

  • Code Optimization

  • Easy to traverse data

  • Easy to sort data

  • Random Access

Disadvantage:

  • Fixed size

Declaration of Array:

  • data_type array_name[size];

  • Example: int num[5];

  • This will create an array of integer data type with array name as num of size 5.

Initialization of Array:

  • A simple way to initialize an array is by its index.

  • Array index starts from 0 and ends with [size-1].

  • Example:

marks[0]=80; //initialization of array

marks[1]=60;

marks[2]=70;

marks[3]=85;

marks[4]=75;