adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C to find the sum of row and columns of a matrix separately.

Program in C  to find the sum of row and columns of a matrix separately.


#include<stdio.h>
#include<conio.h>
   int main()
    {
     int m[3][3],i,j,sum;
  printf("Enter a matrix of size 3 * 3::-\n");
  for(i=0;i<3;i++)
    {
     for(j=0;j<3;j++)
      scanf("%d",&m[i][j]);
    }
 printf("Columns and Rows sum\n");
   for(i=0;i<3;i++)
       { 
  for(sum=0,j=0;j<3;j++)
     {
           sum+=m[i][j];
     printf("%5d",m[i][j]);
         }
         printf("  %c%d",26,sum);
         printf("\n");
     }
    printf("\n");
    for(i=0;i<3;i++)
    {
    for(sum=0,j=0;j<3;j++)
       sum+=m[j][i];
        printf("%4c%d",25,sum);
     }
 getch();
    }
Output:-






Post a Comment

0 Comments