PROGRAM 9
PROGRAM 9
#include<iostream.h>
#include<conio.h>
class matr
{
public:
int a[10][10];
double b[10][10],c[10][10];
void mat(int,int);
void mat(int,int,int);
void sum(int,int);
void display(int,int);
};
void matr::mat(int q, int w)
{
int m=q, n=w,i,j;
cout<<"\n Enter the element in Row wise for 1st matrix:";
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
cin>>a[i][j];
}
};
void matr::mat(int e, int r, int o)
{
int m=e,n=r,i,j;
cout<<"\n enter the float element in row wise for 2nd matrix:";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
cin>>b[i][j];
}
}
void matr::sum(int q,int w)
{
int i,j,m=q,n=w;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
}
}
void matr::display(int z,int x)
{
int m=z,n=x,i,j;
cout<<"\n value of matrix A:";
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<"\t"<<a[i][j];
}
cout<<"\n";
}
cout<<"\n value of matrix B:";
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
cout<<"\t"<<b[i][j];
}
cout<<"\n";
}
cout<<"\n sum of matrix is:";
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
cout<<"\t"<<c[i][j];
}
cout<<"\n";
}
}
void main()
{
clrscr();
int a,b,c=0;
cout<<"\n\t funtion overloading";
cout<<"\n\t...................................";
cout<<"\n enter the size of matrix:";
cin>>a>>b;
matr z;
z.mat(a,b);
z.mat(a,b,c);
z.sum(a,b);
z.display(a,b);
getch();
}