C Program to find the Multiplication of two matrices

C Program to find the Multiplication of two matrices. C Program Develop functions
a) To read a given matrix
b) To output a matrix
c) To compute the product of two matrices
Use the above functions to read in two matrices A (MxN) B (NxM), to compute the product of the two matrices, to output the given matrices and the computed matrix in a main function

`/************************************************************ You can use all the programs on  www.c-program-example.com* for personal and learning purposes. For permissions to use the* programs for commercial purposes,* contact info@c-program-example.com* To find more C programs, do visit www.c-program-example.com* and browse!* *                                  Happy Coding***********************************************************/#include <stdio.h>#include <conio.h>#define MAXROWS 10#define MAXCOLS 10void main(){ int A[MAXROWS][MAXCOLS], B[MAXROWS][MAXCOLS], C[MAXROWS][MAXCOLS]; int M, N; /*Function declarations*/ void readMatrix(int arr[][MAXCOLS], int M, int N); void printMatrix(int arr[][MAXCOLS], int M, int N); void productMatrix(int A[][MAXCOLS], int B[][MAXCOLS], int C[][MAXCOLS],   int M, int N); clrscr(); printf("Enter the value of M and Nn"); scanf("%d %d",&M, &N); printf ("Enter matrix An"); readMatrix(A,M,N); printf("Matrix An"); printMatrix(A,M,N); printf ("Enter matrix Bn"); readMatrix(B,M,N); printf("Matrix Bn"); printMatrix(B,M,N); productMatrix(A,B,C, M,N); printf ("The product matrix isn"); printMatrix(C,M,N);}/*Input matrix A*/void readMatrix(int arr[][MAXCOLS], int M, int N){ int i, j; for(i=0; i< M ; i++) {  for ( j=0; j < N; j++)  {   scanf("%d",&arr[i][j]);  } }}void printMatrix(int arr[][MAXCOLS], int M, int N){ int i, j; for(i=0; i< M ; i++) {  for ( j=0; j < N; j++)  {   printf("%3d",arr[i][j]);  }  printf("n"); }}/* Multiplication of matrices */void productMatrix(int A[][MAXCOLS], int B[][MAXCOLS], int C[][MAXCOLS],  int M, int N){ int i, j, k; for(i=0; i< M ; i++) {  for ( j=0; j < N; j++)  {   C[i][j] = 0 ;   for (k=0; k < N; k++)   {    C[i][j] = C[i][j] + A[i][k] * B[k][j];   }  } }}`
`Read more Similar C ProgramsMatrix ProgramsLearn C Programming`

You can easily select the code by double clicking on the code area above.

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!