home
search
help
profile
liking the experience? our app is even better
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now  
showing results for c program to calculate row sum and column sum
1/* C Program to find Sum of columns in a Matrix  */
2
3#include<stdio.h>
4 
5int main()
6{
7    int i, j, rows, columns, a[10][10], Sum;
8    
9    printf("Please Enter Number of rows and columns  :  ");
10    scanf("%d %d", &i, &j);
11    
12    printf("Please Enter the Matrix Row and Column Elements \n");
13    for(rows = 0; rows < i; rows++)
14    {
15        for(columns = 0; columns < j; columns++)
16        {
17            scanf("%d", &a[rows][columns]);
18        }
19    }
20    
21    for(rows = 0; rows < i; rows++)
22    {
23        Sum = 0;
24        for(columns = 0; columns < j; columns++)
25        {
26            Sum = Sum + a[columns][rows];
27        }
28        printf("The Sum of Column Elements in a Matrix =  %d \n", Sum );
29    }
30    
31    return 0;
32}
upvote
downvote
source