ShriRam Changed status to publish July 16, 2022
#include<stdio.h> #include<conio.h> void main() { int a[100][100],b[100][100],c[100][100],i,j,k,r1,c1,r2,c2,sum=0; printf("Enter number of rows and columns of first matrix : \n"); scanf("%d%d",&r1,&c1); printf("Enter number of rows and columns of second matrix : \n"); scanf("%d%d",&r2,&c2); if(r2==c1) { printf("\n Enter First Matrix:"); for(i=0; i<r1; i++) { for(j=0; j<c1; j++) scanf("%d",&a[i][j]); } printf("\n Enter Second Matrix: "); for(i=0; i<r2; i++) { for(j=0; j<c2; j++) scanf("%d",&b[i][j]); } printf("The First Matrix Is : \n"); //print the first matrix for(i=0; i<r1; i++) { for(j=0; j<c1; j++) printf(" %d ",a[i][j]); printf("\n"); } printf("The Second Matrix Is :\n"); // print the second matrix for(i=0; i<r2; i++) { for(j=0; j<c2; j++) printf(" %d ",b[i][j]); printf("\n"); } printf("Multiplication of the Matrices : \n"); for(i=0; i<r1; i++) { for(j=0; j<c2; j++) { c[i][j]=0; for(k=0; k<r1; k++) c[i][j]+=a[i][k]*b[k][j]; printf("\n"); } } printf("The Resulted Matrix Is :\n"); // print the second matrix for(i=0; i<r1; i++) { for(j=0; j<c2; j++) printf(" %d ",c[i][j]); printf("\n"); } } else { printf("Matrix Multiplication is Not Possible"); } }
ShriRam Changed status to publish July 16, 2022