Exercises on Pointers

Test your knowledge on pointers and dynamic memory!

We'll cover the following

In an earlier exercise (in the Complex Data Types section), we saw how to print a matrix and how to multiply two matrices. But the size of the matrix was a fixed constant. Now, we want to accomplish the same using a matrix that’s created using dynamic memory allocation, so that the number of rows and columns of the matrix are passed as variables to a function createMatrix.

Question

Complete the definitions of the functions createMatrix, destroyMatrix, printMatrix, and matrixMult provided below.

Note: For the printMatrix and matrixMult functions, you may make minor modifications to the solution seen in the earlier exercise.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy