Computer Science, asked by jaiprakash9773, 7 months ago

Seenu have a fruit shop. He is arranged the some set of fruits are column and row wise. Seenu needs to find which row and column has maximum number of fruits. Help him to find out.INPUT & OUTPUT FORMAT:Input consists of 2 integers and 1 2D-array. Integers correspond to the size of rows and columns.SAMPLE INPUT & OUTPUT:331 6 82 5 13 8 2Sum of rows is 15 8 13Row 1 has maximum sumSum of columns is 6 19 11Column 2 has maximum sum​

Answers

Answered by Anonymous
0

Answer:

Here is source code of the C program to find the sum of each row & each column of a MxN matrix. The program is successfully compiled and tested using Turbo C compiler in windows environment. The program output is also shown below.

/*

* C program to accept a matrix of order M x N and find the sum

* of each row and each column of a matrix

*/

#include <stdio.h>

void main ()

{

static int array[10][10];

int i, j, m, n, sum = 0;

printf("Enter the order of the matrix\n");

scanf("%d %d", &m, &n);

printf("Enter the co-efficients of the matrix\n");

for (i = 0; i < m; ++i)

{

for (j = 0; j < n; ++j)

{

scanf("%d", &array[i][j]);

}

}

for (i = 0; i < m; ++i)

{

for (j = 0; j < n; ++j)

{

sum = sum + array[i][j] ;

}

printf("Sum of the %d row is = %d\n", i, sum);

sum = 0;

}

sum = 0;

for (j = 0; j < n; ++j)

{

for (i = 0; i < m; ++i)

{

sum = sum + array[i][j];

}

printf("Sum of the %d column is = %d\n", j, sum);

sum = 0;

}

}

Similar questions