MULTIPLICATION OF NxN MATRIX:
Matrix multiplication is possible only if the no. of columns in matrix1 is equal to the no. of rows in matrix2.
(i.e) matrix1 - M x N
matrix2 - N x P
The resultant matrix order will be M x P.
Basic step:
for(i=0;i<row1;i++) //row1- no. of rows in matrix1
{
for(j=0;j<col2;j++) //col2- no. of columns in matrix2
{
mult[i][j]=0;
for(k=0;k<row1;k++)
mult[i][j]+=matrix1[i][k]*matrix2[k][j];
printf("%d\t",mult[i][j]);
}
printf("\n");
}
No comments:
Post a Comment