Load and display the file named multiary.c for an example of a program with doubly dimensioned arrays.
main( )
{
int i,j;
int big[8][8],huge[25][12];
for (i = 0;i < 8;i++)
for (j = 0;j < 8;j++)
big[i][j] = i * j; /* This is a multiplication table */
for (i = 0;i < 25;i++)
for (j = 0;j < 12;j++)
huge[i][j] = i + j; /* This is an addition table */
big[2][6] = huge[24][10] *22;
big[2][2] = 5;
big[big][2][2]...big[2][2]. = 177; /* this is big[5][5] = 177; */
for (i = 0;i < 8;i++) {
for (j = 0;j < 8;j++)
printf("%5d ",big[i][j]);
printf("\n"); /* newline for each increase in i */
}
}
The variable "big" is an 8 by 8 array that contains 8 times 8 or 64 elements total. The first element is "big[0][0]", and the last is "big[7][7]". Another array named "huge" is also defined which is not square to illustrate that the array need not be square. Both are filled up with data, one representing a multiplication table and the other being formed into an addition table. To illustrate that individual elements can be modified at will, one of the elements of "big" is assigned the value from one of the elements of "huge" after being multiplied by 22. Next "big[2][2]" is assigned the arbitrary value of 5, and this value is used for the subscripts of the next assignment statement. The third assignment statement is in reality "big[5][5] = 177" because each of the subscripts contain the value 5. This is only done to illustrate that any valid expression can be used for a subscript. It must only meet two conditions, it must be an integer (although a "char" will work just as well), and it must be within the range of the subscript it is being used for.
The entire matrix variable "big" is printed out in a square form so you can check the values to see if they did get set the way you expected them to.
main( )
{
int i,j;
int big[8][8],huge[25][12];
for (i = 0;i < 8;i++)
for (j = 0;j < 8;j++)
big[i][j] = i * j; /* This is a multiplication table */
for (i = 0;i < 25;i++)
for (j = 0;j < 12;j++)
huge[i][j] = i + j; /* This is an addition table */
big[2][6] = huge[24][10] *22;
big[2][2] = 5;
big[big][2][2]...big[2][2]. = 177; /* this is big[5][5] = 177; */
for (i = 0;i < 8;i++) {
for (j = 0;j < 8;j++)
printf("%5d ",big[i][j]);
printf("\n"); /* newline for each increase in i */
}
}
The variable "big" is an 8 by 8 array that contains 8 times 8 or 64 elements total. The first element is "big[0][0]", and the last is "big[7][7]". Another array named "huge" is also defined which is not square to illustrate that the array need not be square. Both are filled up with data, one representing a multiplication table and the other being formed into an addition table. To illustrate that individual elements can be modified at will, one of the elements of "big" is assigned the value from one of the elements of "huge" after being multiplied by 22. Next "big[2][2]" is assigned the arbitrary value of 5, and this value is used for the subscripts of the next assignment statement. The third assignment statement is in reality "big[5][5] = 177" because each of the subscripts contain the value 5. This is only done to illustrate that any valid expression can be used for a subscript. It must only meet two conditions, it must be an integer (although a "char" will work just as well), and it must be within the range of the subscript it is being used for.
The entire matrix variable "big" is printed out in a square form so you can check the values to see if they did get set the way you expected them to.

