Friday 22 March 2013

C PROGRAM TO MULTIPLY TWO MATRICES

#include<stdio.h>
int n,i,j,k,Mat1[4][4],Mat2[4][4],Mat3[4][4];
void main()
{
printf("Enter order of Matrix\n");
scanf("%d",&n);
printf("Enter the elements of Matrix1");
for(i=0;i for(j=0;j scanf("%d",&Mat1[i][j]);

printf("Enter the elements of Matrixt2");
for(i=0;i for(j=0;j scanf("%d",&Mat2[i][j]);

for(i=0;i {
for(j=0;j {
Mat3[i][j]=0;
for(k=0;k Mat3[i][j]=Mat3[i][j]+Mat1[i][k]*Mat2[k][j];
}
}
printf("Products of Matrix1 And Matrix2\n");
for(i=0;i {
for(j=0;j {
printf("\t%d",Mat3[i][j]);
}
printf("\n");
}
}

No comments:

Post a Comment