#include <stdio.h> int main() { int a[50][50],b[50][50],c[50][50],i,j,k,d[50][50]; printf("enter the elements of 1st matrix\n"); for (i=0; i<3; ++i) { for (j=0; j<3; ++j) { printf("a[%d][%d] = \n",i,j); scanf("%d",&a[i][j]); } } printf("enter the elements of 2nd matrix\n"); for (i=0; i<3; ++i) { for (j=0; j<3; ++j) { printf("b[%d][%d] = \n",i,j); scanf("%d",&b[i][j]); } } for (i=0; i<3; ++i) { for (j=0; j<3; ++j) { c[j][i] = a[i][j]; } } for (i=0; i<3; ++i) { for (j=0; j<3; ++j) { d[i][j]=0; } } for (i=0; i<3; ++i) { for (j=0; j<3; ++j) { for (k=0; k<3; ++k) { d[i][j] = d[i][j] + (c[i][k]*b[k][j]) ; } } } for (i=0; i<3; ++i) { for (j=0; j<3; ++j) { printf("d[%d][%d] = %d ",i,j,d[i][j]); if (j == 2) printf("\n"); } } return 0; }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more