Write C code to complete the function printMatrixCol. Use the pointer/addressing methods to display the array within co

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write C code to complete the function printMatrixCol. Use the pointer/addressing methods to display the array within co

Post by answerhappygod »

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
*/
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply