Sathvikks8

Sum of Rows and Columns

Apr 24th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. void main()
  3. {
  4.         int array[10][10];
  5.         int i,j,m,n,sum=0;
  6.         printf("Enter the order of the matrix: ");
  7.         scanf("%d%d",&m,&n);
  8.         printf("\nEnter the co-efficients of the matrix: ");
  9.         for(i=0;i<m;+i++)
  10.         {
  11.             for(j=0;j<n;j++)
  12.             {
  13.                 scanf("%d",&array[i][j]);
  14.             }
  15.         }
  16.  
  17.         for(i=0;i<m;i++)
  18.         {
  19.             for(j=0;j<n;j++)
  20.             {
  21.                 sum+=array[i][j];
  22.             }
  23.             printf("Sum of the %d row is = %d\n",i+1,sum);
  24.             sum=0;
  25.         }
  26.         sum=0;
  27.         for(j=0;j<n;j++)
  28.         {
  29.             for(i=0;i<m;i++)
  30.             {
  31.                 sum+=array[i][j];
  32.             }
  33.             printf("Sum of the %d column is = %d\n",j+1,sum);
  34.             sum=0;
  35.  
  36.         }
  37.  
  38. }
Add Comment
Please, Sign In to add comment