Multiplication Of Two Matrices



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

using namespace std;

void main()
{
       int a[2][2],b[2][2],c[2][2],x,y,multi;

       cout<<"please enter the elements of 1st matrix \n";
       for(x=0;x<2;x++)
       {
              for(y=0;y<2;y++)
              {
                     cin>>a[x][y];
              }
       }
       cout<<"please enter the elements of 2nd matrix \n";
       for(x=0;x<2;x++)
       {
              for(y=0;y<2;y++)
              {
                     cin>>b[x][y];
              }
       }
       for(x=0;x<2;x++)
       {
              for(y=0;y<2;y++)
              {
                     c[x][y]=a[x][y]*b[x][y];
              }
       }
       cout<<"the product of the matrices is\n";
       for(x=0;x<2;x++)
       {
              for(y=0;y<2;y++)
              {
       cout<<"\t"<<c[x][y];
              }
              cout<<"\n";
       }
      
      
      
       getch();
}

 

No comments:

Post a Comment