#include<iostream.h>
#include<conio.h>
void main()
{
int r1,r2,c1,c2,i,j,k;
int ham[12][12];
int tum[12][12];
int mul[12][12]={0,0,0,0,0,0,0,0,0,0,0,0};
cout<<"enter no of row of first matrix ";
cin>>r1;
cout<<"enter no of columns of first matrix ";
cin>>c1;
cout<<endl<<"enter no of row of 2nd matrix ";
cin>>r2;
cout<<"enter no of columns of 2nd matrix ";
cin>>c2;
if(c1==r2)
{
cout<<"\n\n";
for(i=0;i<r1;i++)
for(j=0;j<c1;j++)
{cout<<"ham["<<i<<"]["<<j<<"]"<<"\t" ;
cin>>ham[i][j];}
cout<<"\n\n";
for(i=0;i<r2;i++)
for(j=0;j<c2;j++)
{cout<<"tum["<<i<<"]["<<j<<"]"<<"\t";
cin>>tum[i][j];}
cout<<"\n\n";
cout<<"MULTIPLICATION OF THE MATRICES IS"<<endl<<endl;
for(i=0;i<r1;i++) //control no of rows
{for(j=0;j<c2;j++) //control no of columns
{for(k=0;k<c1;k++) //control two parts of each member
mul[i][j]=mul[i][j]+ham[i][k]*tum[k][j];
cout<<mul[i][j]<<"\t";}
cout<<endl;}
} //end of if
else
cout<<"matrices are not in order";
getch();
} //end of main body
#include<conio.h>
void main()
{
int r1,r2,c1,c2,i,j,k;
int ham[12][12];
int tum[12][12];
int mul[12][12]={0,0,0,0,0,0,0,0,0,0,0,0};
cout<<"enter no of row of first matrix ";
cin>>r1;
cout<<"enter no of columns of first matrix ";
cin>>c1;
cout<<endl<<"enter no of row of 2nd matrix ";
cin>>r2;
cout<<"enter no of columns of 2nd matrix ";
cin>>c2;
if(c1==r2)
{
cout<<"\n\n";
for(i=0;i<r1;i++)
for(j=0;j<c1;j++)
{cout<<"ham["<<i<<"]["<<j<<"]"<<"\t" ;
cin>>ham[i][j];}
cout<<"\n\n";
for(i=0;i<r2;i++)
for(j=0;j<c2;j++)
{cout<<"tum["<<i<<"]["<<j<<"]"<<"\t";
cin>>tum[i][j];}
cout<<"\n\n";
cout<<"MULTIPLICATION OF THE MATRICES IS"<<endl<<endl;
for(i=0;i<r1;i++) //control no of rows
{for(j=0;j<c2;j++) //control no of columns
{for(k=0;k<c1;k++) //control two parts of each member
mul[i][j]=mul[i][j]+ham[i][k]*tum[k][j];
cout<<mul[i][j]<<"\t";}
cout<<endl;}
} //end of if
else
cout<<"matrices are not in order";
getch();
} //end of main body
0 comments:
Post a Comment