Write C code for the following questions. //a: array pointer, m: # of rows, n: # of columns void printMatrixRowMajor (in
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Write C code for the following questions. //a: array pointer, m: # of rows, n: # of columns void printMatrixRowMajor (in
questions. //a: array pointer, m: # of rows, n: # of columns void printMatrixRowMajor (int *a, int m, int n) { int row, col; int *ptr; printf("\nMatrix row major fashion: \n"); ptr = a; // ADD YOUR CODE HERE } //a: array pointer, m: # of rows, n: # of columns void printMatrixColMajor (int *a, int m, int n) { int row, col; int *ptr; printf("\nMatrix column major fashion: \n"); ptr = a; // ADD YOUR CODE HERE } main () { int m= 3, n = 4; int a [m] [n]; int row, col; for (row = 0; row < m; row++) for (col= 0; col < n; col++) a[row] [col] = row * n + co; (&a [0] [0], m, n); (&a [0] [0], m, n); printMatrixRowMajor printMatrixColMajor OUTPUT Matrix row major fashion: 0 1 2 3 4 5 6 7 8 9 10 11 Matrix column major fashion: 048 159 26 10 3 7 11 */ a) Use the pointer/addressing methods in row major fashion to display the array. Complete the function printMatrixRowMajor. b) Use the pointer/addressing methods in column major fashion to display the array. Complete function printMatrixColMajor
Write C code for the following