0
#include<iostream>
#include<iomanip>

using namespace std;

int main()

{
    int a[10][10],b[10][10],c[10][10],i,j,k,r1,r2,c1,c2;
    
    cout<<"Enter the order of I matrix\n";
    cin>>r1>>c1;
    
    cout<<"Enter the order of II matrix\n";
    cin>>r2>>c2;
    
    cout<<"Enter the "<<r1*c1<<" elements for I matrix \n";
    for(i=0;i<r1;++i)
    for(j=0;j<c1;++j)
    cin>>a[i][j];
    
    cout<<"Enter the "<<r2*c2<<" elements for II matrix \n";
    for(i=0;i<r2;++i)
    for(j=0;j<c2;++j)
    cin>>b[i][j];
    
    for(i=0;i<r1;++i)
     for(j=0;j<c2;++j)
    {
      c[i][j]=0;
      for(k=0;k<c1;++k)
      c[i][j]=c[i][j]+a[i][k]*b[k][j];
    }

cout<<"\n multiplication of matrices\n";
for(i=0;i<r1;++i)
for(j=0;j<c2;++j)
{
   c[i][j]=0;
   for(k=0;k<c2;++k)
   c[i][j]=c[i][j]+b[i][k]*b[k][j];
  
}


cout<<"\n multiplication of marrices\n";

   for(i=0;i<r1;++i)
    {
     for(j=0;j<c2;++j)
     cout<<setw(5)<<c[i][j];
     cout<<endl;
     }

return 0;
}

kindly check if it is having an error..

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by thEhAckEr
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.