find sum of individual column of a matrix in c

/* C Program to find Sum of columns in a Matrix  */

#include<stdio.h>
 
int main()
{
    int i, j, rows, columns, a[10][10], Sum;
    
    printf("Please Enter Number of rows and columns  :  ");
    scanf("%d %d", &i, &j);
    
    printf("Please Enter the Matrix Row and Column Elements \n");
    for(rows = 0; rows < i; rows++)
    {
        for(columns = 0; columns < j; columns++)
        {
            scanf("%d", &a[rows][columns]);
        }
    }
    
    for(rows = 0; rows < i; rows++)
    {
        Sum = 0;
        for(columns = 0; columns < j; columns++)
        {
            Sum = Sum + a[columns][rows];
        }
        printf("The Sum of Column Elements in a Matrix =  %d \n", Sum );
    }
    
    return 0;
}

4.56
9
Ali_m 140 points

                                    #include &lt;stdio.h&gt;
void main ()
{
    int i,j,matrix[10][10],m,n,sum=0;

    printf(&quot;Enter number of rows of matrix  : &quot;);
    scanf(&quot;%d&quot;, &amp;m);
    printf(&quot;Enter number of columns of matrix  : &quot;);
    scanf(&quot;%d&quot;, &amp;n);

    printf(&quot;\n&quot;);

    for (i = 0; i &lt; m; i++)
    {
        for (j = 0; j &lt; n; j++)
        {
            printf(&quot;Enter element of matrix [%d][%d]: &quot;, i, j);
            scanf(&quot;%d&quot;, &amp;matrix[i][j]);
        }
    }

    printf(&quot;\n&quot;);

    for (j = 0; j &lt; n; ++j)
    {
        for (i = 0; i &lt; m; ++i)
        {
            sum = sum + matrix[i][j];
        }

        printf(&quot;Sum of the %d column is = %d\n&quot;, j+1, sum);
        sum = 0;
    }
}

4.56 (9 Votes)
0
4.67
6
Azrantha 105 points

                                    #include &lt;stdio.h&gt;
void main ()
{
    int i,j,matrix[10][10],m,n,sum=0;

    printf(&quot;Enter number of rows of matrix  : &quot;);
    scanf(&quot;%d&quot;, &amp;m);
    printf(&quot;Enter number of columns of matrix  : &quot;);
    scanf(&quot;%d&quot;, &amp;n);

    printf(&quot;\n&quot;);

    for (i = 0; i &lt; m; i++)
    {
        for (j = 0; j &lt; n; j++)
        {
            printf(&quot;Enter element of matrix [%d][%d]: &quot;, i, j);
            scanf(&quot;%d&quot;, &amp;matrix[i][j]);
        }
    }

    printf(&quot;\n&quot;);

    for (i = 0; i &lt; m; ++i)
    {
        for (j = 0; j &lt; n; ++j)
        {
            sum = sum + matrix[i][j] ;
        }

        printf(&quot;Sum of the %d row is = %d\n&quot;, i+1, sum);
        sum = 0;

    }
}

4.67 (6 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
write a c program to find row sum and column sum of a matrix find sum of matrix in c Write a C Program to find the sum of all elements of a matrix. sum of row of array in c sum columns of matrix c c program to find sum of all elements of each column of a matrix c program to find sum of all elements of each row of a matrix c sum of individual row and column in 2d array sum of each row and column matrix c sum of elements in a matrix in C programming find sum of individual column of a matrix in c find sum of individual row of a matrix in c column and row sum in c sum of colum of mattrix in c c programm to print the sum of coloum elements in a matrixx program to find the sum of each row and each column of a matrix in c row sum and column sum of a matrix in c write a program to find the sum of the rows, column of a matrix in c write a program in c to find sum of rows and columns of a matrix c program to find sum of each column in a 2d array matrix sum by column c column major matrix sum c c Program to find the sum of each row and each column of a matrix find the sum of all column elements in matrix c sum of colum of matrix in c Fourth row sum Matrix Write a program to get a 3x3 matrix and display a matrix of order 4x4, with fourth row and column as sum of rows and columns respectively. c program to calculate row sum and column sum write a program to print the sum of each column of the matrix matrix sum in c sum of 2 matrix by using function in c sum of rows of matrix in c sum of column elements in c sum row in matrix c summing rows of arrays in c sum of rows and columns in 2d array in c adding sum of columns in 2d array in c sum of columns in 2d array in c adding sum of columns and rows in c sum of all column in matrix in c
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source