Answer 2D2

#include <stdio.h>
#include <stdlib.h>

/* Puzzle DD02 -- fill an N by M integer array print it out. */
#define Nrows 3
#define Mcols 4

int main()
{
  int x[Nrows][Mcols] = { {1,2,3,4}, {10,20,30,40}, {-10,-20,-34, 99} } ;
    
  int r, c;  /* row and column indexes for the array */
    
  /* Print out the array */
  for ( r=0; r<Nrows; r++ )
  {
    for ( c=0; c<Mcols; c++ )
      printf("%4d ", x[r][c] );
    printf("\n");  
  }
  
  printf("\n");
  system("pause");
  return 0;
}


Back to Puzzle Home