

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


#include <stdio.h> #include<math.h>
int main() { int a[3][3],b[3][3],r1,c1,r2,c2,i,j,k,mul[3][3]; printf("Input order of first matrix\n"); scanf("%d\n%d",&r1,&c1); printf("Input order of second matrix\n"); scanf("%d\n%d",&r2,&c2); printf("Input elements of first matrix\n"); for(i=0;i<r1;i++){ for(j=0;j<c1;j++){ scanf("%d",&a[i][j]); } } printf("Input element of second matrix\n"); for(i=0;i<r2;i++){ for(j=0;j<c2;j++){ scanf("%d",&b[i][j]); } }
if(c1!=r1){ printf("Multiplication is not possible"); } else{ printf("multiply of the matrix=\n"); for(i=0;i<r1;i++){ for(j=0;j<c2;j++){ mul[i][j]=0; for(k=0;k<c1;k++){ mul[i][j]+=a[i][k]*b[k][j]; } } } for(i=0;i<r1;i++){ for(j=0;j<c2;j++){ printf("%d\t",mul[i][j]); } printf("\n"); } }
return 0;
}