Allows data of the same type to be kept under a single variable name.The number of elements is specified when defining.
Identification Examples:
Example 1: int array1[12];
Example 2: char array2[20];
Assign elements to arrays examples:
Example 1: int array1[5] = {1,2,3,4,5};
Example 2: int array2[5] = {6,7,8}; //last two elements is 0
Example 3:
int array3[5], i;
for (i = 0; i<5; i++){
array3[i] = i;
printf("%d\n", array3[i]);}
Multidimensional arrays examples:
Example 1:
int array[3][2] = {{1,2},{3,4},{5,6}};
int i,j;
for(i = 0;i<3; i++){
for(j=0; j<2; j++){
printf("%d\t", array[i][j]);}
printf("\n");}
Example 2:
int array[3][2][2] = {1,2,3,4,5,6,7,8,9,10,11,12};
int i,j,k;
for(i = 0; i<3; i++){
for(j = 0; j<2; j++){
for(k = 0; k<2; k++){
printf("%d\t", array[i][j][k]);
}
printf("\n");
}
printf("\n");
}