0% found this document useful (0 votes)
3 views

PROGRAM 9

The document contains a C++ program that demonstrates function overloading through a class named 'matr' for matrix operations. It allows the user to input two matrices, computes their sum, and displays the original matrices along with the result. The program utilizes basic input/output operations and matrix manipulation techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

PROGRAM 9

The document contains a C++ program that demonstrates function overloading through a class named 'matr' for matrix operations. It allows the user to input two matrices, computes their sum, and displays the original matrices along with the result. The program utilizes basic input/output operations and matrix manipulation techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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();
}

You might also like