C program for matrix multiplication

This program implements matrix multiplication in the C programming language.


Basic mathematics:

  • A * B is different from B * A.
  • To multiply two matrices, the matrices must be multiplicable, i.e. Number of columns of the first matrix must be equal to the number of rows of the second matrix.
  • The order of the multiplied matrix is row1 * column2, where row1 is the number of rows in the first matrix and column2 is the number of columns in the second matrix

Program: Multiply matrix in C


Sample output #1: Print product of two matrices in C

Enter the number of rows and columns of first matrix: 3 3 
Enter the elements of first matrix: 2 1 5 2 0 3 1 6 8
Enter the number of rows and columns of second matrix: 3 2
Enter the elements of second matrix: 1 4 2 0 1 3
Product of entered matrices:
9       23
5       17
21      28

Sample output #2: Matrix not multiplicable

Enter the number of rows and columns of first matrix: 3 3 
Enter the elements of first matrix: 2 1 5 2 0 3 1 6 8
Enter the number of rows and columns of second matrix: 2 3
Matrices with entered orders can't be multiplied with each other.

Share your code and queries in the comments.

Share this code and algorithm with your programmer friends.

Follow us on twitter.

About ᴾᴿᴼᵍʳᵃᵐᵐᵉʳ

Linux and Python enthusiast, in love with open source since 2014, Writer at programming-articles.com, India.

View all posts by ᴾᴿᴼᵍʳᵃᵐᵐᵉʳ →

Leave a Reply

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