Matrix Multiplication in C

In this post, we will see how to do matrix multiplication in C.

If we want to multiply two matrices, then number of columns in first matrix must be equal to number of rows in second matrix. If this condition is not satisfied, below program will give you an error message.

Here is simple demonstration of matrix multiplication in C.


Implementation:

Output:

Row number of 1st matrix :3
Column number of 1st matrix : 3
Row number of 2nd matrix :3
Column number of 2nd matrix : 3
Enter the elements of 1st matrix
1 2 3
4 5 6
7 8 9
Enter the elements of 2nd matrix
1 2 3
4 5 6
7 8 9
The elements of new matrix
30 36 42
66 81 96
102 126 150

That’s all about matrix multiplication in C.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *