daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Apr 17th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<time.h>
  3. #include<stdlib.h>
  4.  
  5. void add_matrix(int matrix1[5][6], int matrix2[5][6], int matrix3[5][6]);
  6.  
  7. int main()
  8. {
  9.     int a[5][6], b[5][6], matrix[5][6] = { 0 };
  10.     int i, j;
  11.  
  12.     srand((unsigned)time(NULL));
  13.  
  14.     printf("matrix1\n");
  15.     for (i = 0; i < 5; i++) {
  16.         for (j = 0; j < 6; j++) {
  17.             a[i][j] = rand() % 100 + 1;
  18.             printf("%3d ", a[i][j]);
  19.         }
  20.         printf("\n");
  21.     }
  22.     printf("\n\n\n");
  23.  
  24.     printf("matrix2\n");
  25.     for (i = 0; i < 5; i++) {
  26.         for (j = 0; j < 6; j++) {
  27.             b[i][j] = rand() % 100 + 1;
  28.             printf("%3d ", b[i][j]);
  29.         }
  30.         printf("\n");
  31.     }
  32.     printf("\n\n\n");
  33.  
  34.     printf("result\n");
  35.     add_matrix(a[5][6], b[5][6], matrix[5][6]);
  36.  
  37.     printf("\n");
  38.  
  39.  
  40. }
  41.  
  42. void add_matrix(int matrix1[5][6], int matrix2[5][6], int matrix3[5][6]) {
  43.     int i, j;
  44.     for (i = 0; i < 5; i++) {
  45.         for (j = 0; j < 6; j++) {
  46.             matrix3[i][j] = matrix1[i][j] + matrix2[i][j];
  47.             printf("%3d ", matrix3[i][j]);
  48.         }
  49.         printf("\n");
  50.     }
  51. }
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
 
Top