Advertisement
Osher15151

sdfdsf

Jun 26th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define size 4
  4.  
  5.  
  6. void main()
  7. {
  8.     int arr[size][size], row, col, sum = 0 ,sum2 = 0;
  9.     printf("Give me 16 Numbers tfadal : \n");
  10.  
  11.     for (row = 0; row < size; row++)
  12.     {
  13.         for (col = 0; col < size; col++)
  14.         {
  15.             scanf_s("%d", &arr[row][col]);
  16.         }
  17.     }
  18.  
  19.     for (row = 0; row < size; row++)
  20.     {
  21.         sum = 0;
  22.         for (col = 0; col < size; col++)
  23.         {
  24.             sum+= arr[row][col];
  25.         }
  26.         printf("\nThe Sum of Elements of Rows in a Matrix = %d", sum);
  27.     }
  28.     printf("\n");
  29.     for (row = 0; row < size; row++)
  30.     {
  31.         sum2 = 0;
  32.         for (col = 0; col < size; col++)
  33.         {
  34.             sum2 += arr[col][row];
  35.         }
  36.        
  37.         printf("Sum of elements of column %d = %d\n", row + 1, sum2);
  38.     }
  39.  
  40.  
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement