My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

program to find the sum of rows of the matrix

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int x[10][10],n,m;
 cout<<"number of rows and colomns"<<endl;
 cin>>m>>n;
 cout<<"enter the elements: ";
 for(int i=0;i<m;i++)
 for(int j=0;j<n;j++)
 cin>>x[i][j];
 cout<<"sum of rows"<<endl;
 for(i=0;i<m;i++)
 {
  int sum=0;
   for(j=0;j<n;j++)
   {
    cout<<x[i][j]<<"\t";
    sum+=x[i][j];
    }
   cout<<"="<<sum<<endl;
  }
 cout<<"sum of colomns"<<endl;
 for(j=0;j<n;j++)
 {
  int sum=0;
  for(i=0;i<m;i++)
   {
    cout<<x[i][j]<<"\t";
    sum+=x[i][j];
    }
    cout<<"="<<sum<<endl;
  }
 getch();
 }

0 comments: