/*
Multidimensional arrays.
*/
#include <stdio.h>
main()
{
/* Declaration Statements */
char season[4][3][4];
short row, column, j;
char *TEMP;
clrscr();
printf("C71.C -> Multidimension arrays\n");
/* Read in month code, one per line */
for (column = 1; column <= 4; column++)
{
for (row = 1; row <= 3; row++)
{
printf("\nEnter Element ( %d,%d ) : ",row,column);
fgets(season[row - 1][column - 1], 4, stdin);
TEMP = strchr(season[row - 1][column - 1], '\n');
if (TEMP != NULL)
*TEMP = 0;
} /* End of inner for{} loop */
} /* End of outer for{} loop */
/* Print matrix method 1 */
printf("\n\nMethod 1 :\n\n");
for (column = 1; column <= 3; column++)
{
for (row = 1; row <= 4; row++)
printf("%s%2c", season[row - 1][column - 1], ' ');
putchar('\n');
} /* End of outer for{} loop */
/* Print matrix method 2 */
printf("\nMethod 2 :\n");
putchar('\n');
for (row = 1; row <= 4; row++) {
for (column = 1; column <= 3; column++)
printf("%s%2c", season[row - 1][column - 1], ' ');
putchar('\n');
} /* End of outer for{} loop */
return(0);
}
/* End of Program C71 */
/*
INPUT :1 2 3 4 5 6 7 8 9 0 1 2OUTPUT :
C71.C -> Multidimension arrays Enter Element ( 1,1 ) : 1 Enter Element ( 2,1 ) : 2 Enter Element ( 3,1 ) : 3 Enter Element ( 1,2 ) : 4 Enter Element ( 2,2 ) : 5 Enter Element ( 3,2 ) : 6 Enter Element ( 1,3 ) : 7 Enter Element ( 2,3 ) : 8 Enter Element ( 3,3 ) : 9 Enter Element ( 1,4 ) : 0 Enter Element ( 2,4 ) : 1 Enter Element ( 3,4 ) : 2 Method 1 : 1 4 7 0 2 5 8 1 3 6 9 2 Method 2 : 1 2 3 4 5 6 7 8 9 0 1 2 */
Last modified: 22/07/97