#include <stdio.h>
void main ()
{
static int m1[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-efficient s of the matrix\n”);
for (i=0;i<m;++i)
{
for (j=0;j<n;++j)
{
scanf (“%d”,&m1[i][j]);
}
}
for (i=0;i<m;++i)
{
for (j=0;j<n;++j)
{
sum = sum + m1[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+m1[i][j];
}
printf (“Sum of the %d column is = %d\n”, j,sum);
sum = 0;
}
} /*End of main() */
/*—————————————————
Output
Enter the order of the matrix
3 3
Enter the co-efficient s of the matrix
1 2 3
4 5 6
7 8 9
Sum of the 0 row is = 6
Sum of the 1 row is = 15
Sum of the 2 row is = 24
Sum of the 0 column is = 12
Sum of the 1 column is = 15
Sum of the 2 column is = 18
—————————————————-*/
Not Satisfied ? Just search & get the result
Related posts:
- C program to read a matrix A (MxN) and to find the following using functions a) Sum of the elements of each row b) Sum of the elements of each column c) Find the sum of all the elements of the matrix Output the computed results with suitable headings
- Sample – Program to find the sum of each row & column of a matrix of size n x m and if matrix is square, find the sum of the diagonals also..
- C program to accept a matrix of given order and interchange any two rows and columns in the original matrix
- C program to accept a matrix of order M x N and store its elements and interchange the main diagonal elements of the matrix with that of the secondary diagonal elements
- C program to read two matrices A (MxN) and B(MxN) and perform addition OR subtraction of A and B. Find the trace of the resultant matrix. Output the given matrix, their sum or Differences and the trace.
