Computer Science, asked by pallabroy4447, 3 days ago

Write a C program to multiply two matrices. Test case: Input : 3 3 22 41 31 54 32 65 78 69 54 33 11 65 34 62 54 56 89 65 3*3 row column value, rest input matrix elements Output: Multiplication result of two matrices = 3856 5543 5659 6510 8363 9463. 7944 9942 12306

Answers

Answered by samarthkrv
0

Answer:

#include <stdio.h>

int main() {

   int r , c , r1 , c1;

   int prod = 1 , prod1 = 1;

   printf("Enter rows and collumns for the first matrix- \n");

   scanf("%d" , &r);

   scanf("%d" , &c);

   int arr[r][c];

   printf("Enter all elements in the first matrix - \n");

   for(int i = 0; i < r; i++){

       for(int j = 0; j < c; j++){

           scanf("%d" , &arr[i][j]);

       }

   }

   printf("The first matrix \n");

    for(int i = 0; i < r; i++){

       for(int j = 0; j < c; j++){

           prod = prod*arr[i][j];

           printf("%d " , arr[i][j]);

       }

       printf("\n");

   }printf("Enter rows and collumns for the second matrix- \n");

   scanf("%d" , &r1);

   scanf("%d" , &c1);

   int arr1[r1][c1];

   printf("Enter all elements in the second matrix - \n");

   for(int i = 0; i < r1; i++){

       for(int j = 0; j < c1; j++){

           scanf("%d" , &arr1[i][j]);

       }

   }

   printf("The second matrix \n");

    for(int i = 0; i < r1; i++){

       for(int j = 0; j < c1; j++){

           prod1 = prod1 * arr[i][j];

           printf("%d " , arr1[i][j]);

       }

       printf("\n");

   }

   int x = prod*prod1;

   printf("The product of both the matrixes are %d \n" , x);

   return 0;

}

Explanation:

Similar questions