find sum of individual column of a matrix in c

Solutions on MaxInterview for find sum of individual column of a matrix in c by the best coders in the world

showing results for - "find sum of individual column of a matrix in c"
Ange
19 Apr 2017
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}
Sam
19 Oct 2017
1#include <stdio.h>
2void main ()
3{
4    int i,j,matrix[10][10],m,n,sum=0;
5
6    printf("Enter number of rows of matrix  : ");
7    scanf("%d", &m);
8    printf("Enter number of columns of matrix  : ");
9    scanf("%d", &n);
10
11    printf("\n");
12
13    for (i = 0; i < m; i++)
14    {
15        for (j = 0; j < n; j++)
16        {
17            printf("Enter element of matrix [%d][%d]: ", i, j);
18            scanf("%d", &matrix[i][j]);
19        }
20    }
21
22    printf("\n");
23
24    for (i = 0; i < m; ++i)
25    {
26        for (j = 0; j < n; ++j)
27        {
28            sum = sum + matrix[i][j] ;
29        }
30
31        printf("Sum of the %d row is = %d\n", i+1, sum);
32        sum = 0;
33
34    }
35}
36
Michela
09 Mar 2018
1#include <stdio.h>
2void main ()
3{
4    int i,j,matrix[10][10],m,n,sum=0;
5
6    printf("Enter number of rows of matrix  : ");
7    scanf("%d", &m);
8    printf("Enter number of columns of matrix  : ");
9    scanf("%d", &n);
10
11    printf("\n");
12
13    for (i = 0; i < m; i++)
14    {
15        for (j = 0; j < n; j++)
16        {
17            printf("Enter element of matrix [%d][%d]: ", i, j);
18            scanf("%d", &matrix[i][j]);
19        }
20    }
21
22    printf("\n");
23
24    for (j = 0; j < n; ++j)
25    {
26        for (i = 0; i < m; ++i)
27        {
28            sum = sum + matrix[i][j];
29        }
30
31        printf("Sum of the %d column is = %d\n", j+1, sum);
32        sum = 0;
33    }
34}
35
36
queries leading to this page
column major matrix sum csum of elements in a matrix in c programmingfind the sum of all column elements in matrix cwrite a program to find the sum of the rows 2c column of a matrix in csum of rows and columns in 2d array in csum of each row and column of a matrix in cadding sum of columns and rows in cadding sum of columns in 2d array in csum of colum of mattrix in csum of all column in matrix in csum columns of matrix ccolumn and row sum in cc program to find sum of all elements of each row of a matrixfind sum of individual column of a matrix in cprogram to find the sum of each row and each column of a matrix in cc program to find sum of each column in a 2d arrayc programm to print the sum of coloum elements in a matrixxwrite a program to print the sum of each column of the matrixsum row in matrix csum of row of array in chow to find the sum of each column in a 2d array in csumming rows of arrays in cwrite a c program to find row sum and column sum of a matrixsum of column elements in cwrite a program in c to find sum of rows and columns of a matrixsum of rows of matrix in cfind sum of individual row of a matrix in c write a c program to find the sum of all elements of a matrix find sum of matrix in crow sum and column sum of a matrix in csum of each row and column matrix cc sum of individual row and column in 2d arrayc program to find sum of all elements of each column of a matrixsum of colum of matrix in cfourth row sum matrix write a program to get a 3x3 matrix and display a matrix of order 4x4 2c with fourth row and column as sum of rows and columns respectively sum of 2 matrix by using function in cc program to find the sum of each row and each column of a matrixmatrix sum by column crow sum of matrix in cc program to calculate row sum and column sumc program to find the sum of all elements of each row of a matrixsum of columns in 2d array in cmatrix sum in cfind the sum of rows and columns of the matrix in cfind sum of individual column of a matrix in c