Search This Blog

Translate

C simple program of matrix multiplication

C simple program of matrix multiplication



#include
#include
#define row 2
#define col 2
void main()
{
 int mat1[row][col],mat2[row][col],mat3[row][col],i,j,k;
 clrscr();
 printf("\n Enter first 3x3 matrix:");
 for(i=0;i {
   for(j=0;j    scanf("%d",&mat1[i][j]);
 }
  printf("\n Enter second 3x3 matrix:");
 for(i=0;i {
   for(j=0;j    scanf("%d",&mat2[i][j]);
 }
  for(i=0;i {
   for(j=0;j   {
    for(k=0;k     mat3[i][j] +=mat1[i][k]*mat2[k][j];
   }
 }
 printf("\n Multiplication of matrices:\n ");
  for(i=0;i {
   for(j=0;j    printf("\t%d\t ",mat3[i][j]);
  printf("\n");
 }
 getch();
}

C Program example List

Google+ Badge