by Dinesh Thakur Category: Array Pointer and Union

 

#include <iostream.h>

#include <conio.h>
const int n=2, m=3;
void main( )
{
       float a[n][m];
       float b[m][n];
       float c[n][n];
       int i,j,k;
       clrscr();
      cout<<"Input the Elements of Matrix a ";
      for(i=0;i<n;i++)
            {
                 for(k=0;k<m;k++)
                      cin>>a[i][k];
                      cout<<endl;
           }
                 cout<<"Input the Elements of Matrix b ";
                        for(k=0;k<m;k++)
                            {
                                 for(j=0;j<n;j++ )
                                      cin>>b[k][j];
                                      cout<<endl;
                            }
                                      cout<<endl;
                                      cout<<"Product of the Matrices"<<endl;
                                      for(i=0;i<n;i++)
                                          {
                                              for(j=0;j<n;j++ )
                                                   {
                                                       c[i][j]=0;
                                                       for(k=0;k<m;k++ )
                                                            c[i][j]=c[i][j]+a[i][k]*b[k] [j];
                                                            cout<<c[i] [j]<<" ";
                                                  }
                                                            cout<<endl;
                                         }
                                                            getch();
}

multiplication of two matrices of order 2 * 3 and 3 * 2 respectively



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles