Answers for "write a c program to find row sum and column sum of a matrix"

C
0

find sum of individual column of a matrix in c

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

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

    printf("n");

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

    printf("n");

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

        printf("Sum of the %d column is = %dn", j+1, sum);
        sum = 0;
    }
}
Posted by: Guest on June-25-2021
-1

find sum of individual row of a matrix in c

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

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

    printf("n");

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

    printf("n");

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

        printf("Sum of the %d row is = %dn", i+1, sum);
        sum = 0;

    }
}
Posted by: Guest on June-25-2021

Code answers related to "write a c program to find row sum and column sum of a matrix"

Code answers related to "C"

Browse Popular Code Answers by Language