home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0000 - 0009 / ibm0000-0009 / ibm0003.tar / ibm0003 / LCNOW2.ZIP / EXAMPLES / 2DARRAY.C next >
Encoding:
C/C++ Source or Header  |  1988-07-15  |  504 b   |  33 lines

  1. /*
  2.  * 2 D A R R A Y
  3.  *
  4.  * Create a two-dimensional array, initialize it,
  5.  * and then print all its element values.
  6.  */
  7.  
  8. #define ROWS    4
  9. #define COLS    2
  10.  
  11. int
  12. main(void)
  13. {
  14.     int row, col;
  15.  
  16.     static int data[4][2] = {
  17.         { 11, 22 },
  18.         { 33, 44 },
  19.         { 55, 66 },
  20.         { 77, 88 }
  21.     };
  22.  
  23.     /*
  24.      * Print the contents of the array.
  25.      */
  26.     for (row = 0; row < ROWS; ++row)
  27.         for (col = 0; col < COLS; ++col)
  28.             printf("data[%d][%d] = %d\n",
  29.                 row, col, data[row][col]);
  30.  
  31.     return (0);
  32. }
  33.