// Pantea Aria // static 2D arrays: similar to a Matrix/array // Write a program that reads a 2x3 integer matrix from the user, // then prints it in matrix form (2 rows, 3 columns). #include #define ROWS 2 #define COLS 3 int main(void) { int matrix[ROWS][COLS]; // repeat reading for 6 elements (2 x 3) // I need one loop for the number of rows // loop for the number of cols int i = 0; while (i < ROWS) { int j = 0; while(j < COLS) { printf("Enter an integer:"); // reading for row i, col j scanf("%d", &matrix[i][j]); j++; } i++; } // then prints it in matrix form (2 rows, 3 columns). i = 0; while (i < ROWS) { int j = 0; while(j < COLS) { printf ("%5d ", matrix[i][j]); j++; } printf("\n"); i++; } return 0; }