#include<iostream.h>
#include<conio.h>
class
matrix
{
public:
int
i,j,row,col,a[10][10],b[10][10],c[10][10];
void
getdata();
void
subdata();
void
putdata();
};
void
matrix::getdata()
{
cout<<"Enter
the size of row and column of Matrices:";
cin>>row>>col;
cout<<"Enter
the elements for
Ist"<<row<<"x"<<col<<"matrix:";
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
cin>>a[i][j];
}}
cout<<"Enter
the elements for
IInd"<<row<<"X"<<col<<"matrix:";
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
cin>>b[i][j];
}}}
void
matrix::subdata()
{
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
c[i][j]=a[i][j]-b[i][j];
}}}
void
matrix::putdata()
{
cout<<"the
Difference of matrix is:";
for(i=0;i<row;i++)
{
cout<<"\n";
for(j=0;j<col;j++)
{
cout<<"\t"<<c[i][j];
}}}
void
main()
{
clrscr();
matrix
obj;
obj.getdata();
obj.subdata();
obj.putdata();
getch();
}
No comments:
Post a Comment