SHARE
TWEET

Abuls

a guest Dec 8th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int a[10][10],b[10][10],c[10][10],i,j,k,r1,c1,r2,c2;
  6.     int sum=0;
  7.  
  8.     printf("Enter rows and columns of the matrices: ");
  9.     scanf("%d%d",&r1,&c1);
  10.     scanf("%d%d",&r2,&c2);
  11.     if (r2==c1) {
  12.         printf("Enter First Matrix:\n");
  13.         for (i=0; i<r1; i++)
  14.             for (j=0; j<c1; j++)
  15.                 scanf("%d",&a[i][j]);
  16.  
  17.         printf("Enter Second Matrix:\n");
  18.         for (i=0; i<r2; i++)
  19.             for (j=0; j<c2; j++)
  20.                 scanf("%d",&b[i][j]);
  21.                
  22.         printf("\nMultiplication of the Matrices:\n");
  23.         for (i=0; i<r1; i++) {
  24.             for (j=0; j<c2; j++) {
  25.                 c[i][j]=0;
  26.                 for (k=0; k<r1; k++)
  27.                     c[i][j]+=a[i][k]*b[k][j];
  28.                 printf("%d ",c[i][j]);
  29.             }
  30.             printf("\n");
  31.         }
  32.     }
  33.     else {
  34.         printf("Matrix Multiplication is Not Possible");
  35.     }
  36.    
  37.     return 0;
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top