C Program for Matrix Multiplication using Array


SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
 int a[3][3],b[3][3],c[3][3],i,j,k;
 clrscr();
 printf("\nEnter the A matrix\n");

 for(i=0;i<3;i++)
  {
  for(j=0;j<3;j++)
  {
   printf("A[%d][%d] : ",i+1,j+1);
   scanf("%d",&a[i][j]);
  }
  }
 printf("\nEnter the B matrix\n");
 for(i=0;i<3;i++)
  {
  for(j=0;j<3;j++)
  {
   printf("B[%d][%d] : ",i+1,j+1);
   scanf("%d",&b[i][j]);
  }
  }
 printf("\nMultiplication of the 2 matrices :\n\n");
 for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
     c[i][j]=0;
      for(k=0;k<3;k++)
       {
    c[i][j]+=a[i][k]*b[k][j];
       }
       printf("\t%d",c[i][j]);
    }
    printf("\n\n");
  }
 getch();
}
Previous
Next Post »

1 comments:

Write comments

Still not found what you are looking for? Try again here.