Write a C++ Program for MATRIX ADDITION, through Pointers implementation
//MATRIX ADDITION
//Pointers implementation through pointers
#include
#include
#include
class matrix
{
int **p,row,col;
public:
void getdata(void);
friend void matrixadd(matrix &,matrix &);
void display(void);
};
void matrix :: getdata(void)
{
clrscr();
cout<<"Enter Size of Row:-"; cin>>row;
p=new int *[row];
cout<<"Enter size of Coulumn:-"; cin>>col;
cout<<"\nEnter Data for Matrix of size "<
}
}
}
void matrix :: display(void)
{
cout<<"\n\n\n\n"; cout<<"Display Function\n\n"; for(int i=0;i
{
for(int j=0;j
{
cout<
}
cout<
}
}
void matrixadd(matrix &a,matrix &b)
{
int result[10][10];
if(a.row==b.row &&amp;amp;amp;amp; a.col==b.col)
{
for(int i=0;i
{
for(int j=0;j
{
result[i][j]=a.p[i][j]+b.p[i][j];
}
}
//displaying
for(int x=0;x
{
for(int y=0;y
{
cout<
}
cout<
}
}
else
cout<<"Invalid Matrix Addition Occurs as size differs\n"; } void main() { matrix o1,o2; o1.getdata(); o2.getdata(); clrscr(); o1.display(); o2.display(); getch(); clrscr(); cout<<"\n\nAfter Adition Has been Performed\n\n"; matrixadd(o1,o2); getch(); }