Array is a variable that can hold more than one value of same type. You specify which of the several values you're referring to at any given time by using a numeric subscript. (Arrays in programming are similar to vectors or matrices in mathematics.)
Arrays are of two types:
- One-dimensional arrays
- Multidimensional arrays
Multidimensional arrays : When we create arrays of arrays known as multidimensional arrays. C Programming provide to create multidimensional array.A two dimensional array looks like matrix form.
Syntax :
<array_type> <array_name> [<number of rows>][<number of columns];
Example :
#include <stdio.h>
#include <conio.h>
int main ()
{
int y[5][2] = { {0,0}, {1,2}, {2,4}, {3,6},{4,8}};
int i, j;
for ( i = 0; i < 5; i++ )
{
for ( j = 0; j < 2; j++ )
{
printf("y[%d][%d] = %d\n", i,j, y[i][j] );
}
}
return 0;
}
Compile above and observe output.