C : Programming Language

Array

An array is a simple data structure which groups similar kind of data in contiguos memory location.

For example, we want to store few integer numbers like 19, 89, 24, 90, 34, 57, 24, 84, 88, 72 and 49 then we could declare those many integer variables and store these values in them. Using an array, we do not need to declare those many integer variables but only one array type variable is sufficient. As shown in figure below, all the informations are stored in an array using some index number which are related position in the memory from the beginning address which is the address of 0th element.

Example:

#include <stdio.h>
int main() {
int i, a[10];

//store values in array 'a'
a = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };

//print values stored in array 'a'
for ( i = 0; i < 10, i ++)
printf("%d, ", a[i]);
}

Output:

10, 20, 30, 40, 50, 60, 70, 80, 90, 100,