#include
#include
class matrix
{
private:
int a[10][10],m,n;
public:
void read();
matrix add(matrix);
void show();
};
void matrix::read()
{
cout<<"\n\nENTER ORDER OF MATRIX";
cin>>m>>n;
cout<<"\n\nENTER ELEMENTS";
for(int i=0;i
}
void matrix::show()
{for(int i=0;i
{for(int j=0;j
cout< }
cout<<"\n";}}
matrix matrix::add(matrix mm2)
{
if((m!=mm2.m)||(n!=mm2.n))
{
cout<<"\n\nMATRIX ADDITION IS NOT POSSIBLE";
exit(0);
}
else
{
matrix temp;
temp.m=mm2.m;
temp.n=mm2.n;
for(int i=0;i
return(temp);
} }
int main()
{
clrscr();
matrix m1,m2,m3;
m1.read();
m2.read();
m3=m1.add(m2);
cout<<"\non addition\n";
m3.show();
getch();
}
/**********************************
OUTPUT
************************************
ENTER ORDER OF MATRIX2
2
ENTER ELEMENTS1
1
1
1
ENTER ORDER OF MATRIX2
2
ENTER ELEMENTS1
1
1
1
on addition
22
22
*/
No comments:
Post a Comment