OOPC MATRIX PROGRAM USING + OPERATOR
OOPC MATRIX PROGRAM USING + OPERATOR
# include<iostream>
# define Max 100
using namespace std;
class matrix
{
public:
int i,j,a[Max][Max],r,c;
void getdata ()
{
cout<<"Enter number of rows:";
cin>>r;
cout<<"Enter number of columes:";
cin>>c;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cout<<"Enter value 0f row "<<i<<" - colume "<<j<<" : ";
cin>>a[i][j];
cout<<endl;
}
}
return;
}
void display ()
{
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cout<<a[i][j];
}
cout<<endl;
}
}
};
int main()
{
matrix m1,m2;
int i,j;
m1.getdata();
m2.getdata();
if(m1.c==m2.r)
{
for(i=0;i<m1.r;i++)
{
for(j=0;j<m1.c;j++)
{
cout<<m1.a[i][j] + m2.a[i][j]<<" ";
}
cout<<endl;
}
}
else
{
cout<<"++++++IT IS NOT POSSIBLE+++++++";
}
}
Comments
Post a Comment