void main()
{
int A[5][5],B[5][5],C[5][5],i,j,m,n,p,q,k;
clrscr();
printf(“nnt ENTER A ORDER OF THE FIRST MATRIX M,N…: “);
scanf(“%d,%d”,&m,&n);
printf(“nnt ENTER A ORDER OF THE SECOND MATRIX P,Q…: “);
scanf(“%d,%d”,&p,&q);
if(n == p)
{
printf(“nnt ENTER THE ELEMENTS OF THE FIRST MATRIX..:nn”);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
gotoxy(25+j*4,14+i*2);
scanf(“%d”,&A[i][j]);
}
printf(“n”);
}
printf(“nt ENTER THE ELEMENTS OF THE SECOND MATRIX..:nn”);
for(i=1;i<=p;i++)
{
for(j=1;j<=q;j++)
{
gotoxy(25+j*4,20+m+i*2);
scanf(“%d”,&B[i][j]);
}
printf(“n”);
}
for(i=1;i<=m;i++)
for(j=1;j<=q;j++)
{
C[i][j] = 0;
for(k=1;k<=n;k++)
C[i][j] = C[i][j] + (A[i][k] * B[k][j]);
}
printf(“nt THE PRODUCT OF TWO MATRICES IS…:nnttt “);
for(i=1;i<=m;i++)
{
for(j=1;j<=q;j++)
printf(” %d”,C[i][j]);
printf(“nnttt “);
}
}
else
{
printf(“nt THE ORDERS OF TWO MATRICES ARE NOT CORRECT”);
printf(“nnt HELP : ‘N’ SHOULD BE EQUAL TO ‘P’”);
}
getch();
}
Not Satisfied ? Just search & get the result
Related posts:
- C Program to accept two matrices and check if they are equal
- C program to accept two matrices and find the sum and difference of the matrices
- C program to read two matrices A (MxN) and B(MxN) and perform addition OR subtraction of A and B. Find the trace of the resultant matrix. Output the given matrix, their sum or Differences and the trace.
- C Program – Find the sum of secondary diagonal of a Matrix
- C Program – Find the sum of primary diagonal of a Matrix
