Custom Search

Monday 12 December 2011

Q9)write a program to find row sum and column sum of a matrix


Author: Sanif S S 
Site: theeduzone.blogspot.com 
Email: sanifss@gmail.com

#include<stdio.h>
#include<conio.h>

void main()
{
 clrscr();
 int a[25][25],m,n,i,j,rowsum,columnsum;
 printf("\nenter the order of matrix : ");
 scanf("%d %d",&m,&n);
 printf("\nenter the elements of matrix : ");
 for(i=0;i
 {
  for(j=0;j
  {
   scanf("%d",&a[i][j]);
  }
 }
 printf("\n\n matrix :\n");
 for(i=0;i
 {
  for(j=0;j
  {
   printf(" %d ",a[i][j]);
  }
  printf("\n");
 }
 for(i=0;i
 {
  rowsum=0;
  for(j=0;j
  {
   rowsum=rowsum+a[i][j];
  }
  printf("\nsum of the row %d = %d\n",i+1,rowsum);
 }
 for(j=0;j
 {
  columnsum=0;
  for(i=0;i
  {
   columnsum=columnsum+a[i][j];
  }
  printf("\nsum of the column %d =%d\n",j+1,columnsum);
 }
 getch();
}

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...