Write C code to complete the function printMatrixCol. Usethe pointer/addressing methods to display the array withincolIndex.
// a: array pointer, m: # of rows, n: # of columns
void printMatrixCol(int *a, int m, int n, int colIndex) {
int row;
int *ptr;
printf("\nMatrix col index: %d\n", colIndex);
// ADD YOUR CODE HERE
}
main() {
int m= 3, n = 4;
int a[3][4] = { {0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 10, 11}};
printMatrixCol(&a[0][0], m, n, 2);
}
/* OUTPUT
Matrix col index: 2
2 6 10
*/
Write C code to complete the function printMatrixCol. Use the pointer/addressing methods to display the array within co
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am