Wednesday, February 9, 2011

this is a simple c++ program to find the rowsum and coloum sum of a matrix...




#include<iostream.h>
#include<conio.h>
#include<ctype.h>

void sum(int a[10][10],int m,int n)
{int i,j,s;
for(i=0;i<m;i++)
{s=0;
for(j=0;j<n;j++)
s+=a[i][j];
cout<<"row sum of "<<i<<"row ="<<s;
cout<<"\n";}
for(j=0;j<n;j++)
{s=0;
for(i=0;i<m;i++)
s+=a[i][j];
cout<<"column sum of"<<j<<"column ="<<s;
cout<<"\n";}
}


void main()
{clrscr();
int a[10][10],m,n,i,j;
cout<<"enter the no:of elements";
cin>>m>>n;
cout<<"enter the array";
for(i=0;i<m;i++)
for(j=0;j<n;j++)
cin>>a[i][j];
for(i=0;i<m;i++)
{for(j=0;j<n;j++)
{cout<<a[i][j];
cout<<"\t";}
cout<<"\n";}

sum(a,m,n);
getch();
}

1 comment:

  1. dude...can u pls post the programme to add,subtract,multiply or divie 2 complex nubers????

    ReplyDelete