matrix

Document Sample

```					/* Create a class called matrix and write member functions for reading,
addition,multiplication,computing norm and displaying the matrix */

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>

class matrix
{
int m,n,p,q,k,a[10][10],b[10][10],c[10][10],d[10][10];
public:
matrix mul(matrix);
void disp();
};

{
cout<<"\nEnter the order :";
cin>>m>>n;
cout<<"\nEnter the elements \n";
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>a[i][j];
}
}
}

{
for(int i=0;i<m;i++)
{
for(int j=0;j<q;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
return t1;
}

matrix matrix::mul(matrix t)
{
for(int i=0;i<m;i++)
{
for(int j=0;j<p;j++)
{
d[i][j]=0;
for(k=0;k<q;k++)
{
d[i][j]+=a[i][k]*b[k][j];
}
}
}
return t;
}

void matrix::disp()
{
cout<<"\nThe sum is \n";
for(int i=0;i<m;i++)
{
cout<<endl;
for(int j=0;j<q;j++)
{
cout<<setw(5)<<c[i][j];
}
}
getch();
cout<<"\nThe product is \n";
for(i=0;i<m;i++)
{
cout<<endl;
for(int j=0;j<q;j++)
{
cout<<setw(5)<<d[i][j];
}
}
}
int main()
{
matrix c1,c2,c3,c4;
clrscr();
c3.mul(c2);
c4.disp();
getch();
return 0;
}

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 13 posted: 10/17/2012 language: pages: 2
Description: C programming, C programming