Write a program in C to find the 3*3 matrix multiplication

Showing Answers 1 - 9 of 9 Answers

Code
  1.  

  2. main()

  3. {

  4. int a[10][10],b[10][10],c[10][10]:

  5. int i,j,k;

  6. printf("enter the elements in A matrix");

  7. for(i=0;i<=5;i++)

  8.     for(j=0;j<+5;j++)

  9. {

  10. scanf("%d",&a[i][j]);

  11. }

  12. printf("enter b matrix");

  13. for(i=0;i<=5;i++)

  14.     for(j=0;j<+5;j++)

  15. {

  16. scanf("%d",&b[i][j]);

  17.  

  18.  

  19. }

  20. c[0][0]=0;

  21. for(i=0;i<=5;i++)

  22. {                    [  this is main logic ]

  23. for(j=0;j<=5;j++)

  24. {

  25. for(k=0;k<=5;k++)

  26. {

  27. c[i][j]=c[i][j]=c[k][j]+a[i][k]*b[k][j];

  28.  

  29. }

  30. }

  31. printf("multiplication matrix is");

  32. for(i=0;i<=5;i++)

  33. for(j=0;j<=5;j++)

  34. printf("%d",c[i][j]):

  35. }

  36.  

Check this out:

Code
  1. int a[3][3],b[3][3],c[3][3];

  2.  

  3.         int i,j,k;

  4.        

  5.         printf("enter the elements in A matrix:

  6. ");

  7.         for(i=0;i<=2;i++)

  8.         {

  9.                 for(j=0;j<=2;j++)

  10.                 {

  11.                         scanf("%d",&a[i][j]);

  12.                 }

  13.         }

  14.  

  15.         printf("enter b matrix:

  16. ");

  17.         for(i=0;i<=2;i++)

  18.         {

  19.                 for(j=0;j<=2;j++)

  20.                 {

  21.                         scanf("%d",&b[i][j]);

  22.                 }

  23.         }

  24.  

  25.        

  26.         for(i=0;i<=2;i++)

  27.         {                    

  28.        

  29.                 printf("

  30. ");

  31.                 for(j=0;j<=2;j++)

  32.                 {

  33.        

  34.                         c[i][j]=0;

  35.                         for(k=0;k<=2;k++)

  36.                         {

  37.                                  c[i][j] = c[i][j]+a[i][k] * b[k][j];

  38.                         }

  39.                 }

  40.         }

  41.         printf("multiplication matrix is:

  42. ");

  43.         for(i=0;i<=2;i++)

  44.         {

  45.                 for(j=0;j<=2;j++)

  46.                 {

  47.                         printf("%d      ",c[i][j]);

  48.                 }

  49.                 printf("

  50. ");

  51.         }

  Was this answer useful?  Yes

Neha

  • Mar 26th, 2018
 

Q~Program to perform matrix multiplication of 3×3 using strassens algorithm. Calculate total number of addition and multiplication operation while computing the matrix multiplication

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions