KAR98S

Matrix Multiplication.c

Feb 25th, 2021
620
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main()
  4. {
  5.     int a[10][10], b[10][10], mul[10][10] = {0}, r, c, i, j, k;
  6.     printf("enter the number of row=");
  7.     scanf("%d", &r);
  8.     printf("enter the number of column=");
  9.     scanf("%d", &c);
  10.     printf("enter the first matrix element=\n");
  11.     for (i = 0; i < r; i++) {
  12.         for (j = 0; j < c; j++) {
  13.             scanf("%d", &a[i][j]);
  14.         }
  15.     }
  16.     printf("enter the second matrix element=\n");
  17.     for (i = 0; i < r; i++) {
  18.         for (j = 0; j < c; j++) {
  19.             scanf("%d", &b[i][j]);
  20.         }
  21.     }
  22.  
  23.     printf("multiply of the matrix=\n");
  24.     for (i = 0; i < r; i++) {
  25.         for (j = 0; j < c; j++) {
  26.             for (k = 0; k < c; k++) {
  27.                 mul[i][j] += a[i][k] * b[k][j];
  28.             }
  29.         }
  30.     }
  31.     //for printing result
  32.     for (i = 0; i < r; i++) {
  33.         for (j = 0; j < c; j++) {
  34.             printf("%d\t", mul[i][j]);
  35.         }
  36.         printf("\n");
  37.     }
  38.     return 0;
  39. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×