Problem: Write a C program to multiply two matrices.

Matrix in c programming language is represented by a 2D array, where the order of a matrix is used as the dimensions for the array.

Matrix Multiplication is only possible when the number of columns of the first matrix is equal to the number of rows of the second matrix.

Matrix multiplication in C

Also, the order of the resultant matrix depends on the order of the multiplication matrices as follows:

  • row = row of the first matrix
  • column = column of the second matrix.

After verifying that multiplication is possible for the two matrices, we multiply them using standard matrix multiplication rule as used in the Mathematics subject.

Here is the c program where we are multiplying two matrices after taking all the inputs from the user.

Output

Matrix multiplication in C

That’s all for the matrix multiplication in C. If you face any problem in this C program then comment below.

Leave a Reply