Multidimensional Arrays Table of 1 to 34 Numbers

Multidimensional Arrays Table of 1 to 34 Numbers | Print Numbers in matrix format | Tabular Printing of numbers in C



#include 

const int num_rows = 7;
const int num_columns = 5;

int
main()
{
  int box[num_rows][num_columns];
  int row, column;

  for(row = 0; row < num_rows; row++)
    for(column = 0; column < num_columns; column++)
      box[row][column] = column + (row * num_columns);

  for(row = 0; row < num_rows; row++)
    {
      for(column = 0; column < num_columns; column++)
        {
          printf("%4d", box[row][column]);
        }
      printf("\n");
    }
  return 0;
}

No comments:

Post a Comment