#include <iostream.h>
#include <conio.h>
void main ()
{
int i , j , k ;
int set1[3][2] , set2[2][4] , multi[3][4] ;
cout<<" Enter values of first 3X2 matrix :\n" ;
for (i=0 ; i<3 ; i++)
{
for (j=0 ; j<2 ; j++)
cin >> set1[i][j] ;
}
cout<<" Enter values of second 2X4 matrix :\n" ;
for (i=0 ; i<2 ; i++)
{
for (j=0 ; j<4 ; j++)
cin >> set2[i][j] ;
}
cout<<" The first 3X2 matrix is :\n" ;
for (i=0 ; i<3 ; i++)
{
for (j=0 ; j<2 ; j++)
cout <<set1[i][j]<<"\t" ;
cout <<"\n" ;
}
cout <<"\n" ;
cout<<"The second 2X4 matrix is :\n" ;
for (i=0 ; i<2 ; i++)
{
for (j=0 ; j<4 ; j++)
cout <<set2[i][j]<<"\t" ;
cout <<"\n" ;
}
cout <<"\n" ;
for (i=0 ; i<3 ; i++)
for (k=0 ; k<4 ; k++)
multi[i][k] = 0;
for (i=0 ; i<3 ; i++)
{
for (j=0 ; j<2 ; j++)
{
for (k=0 ; k<4 ; k++)
multi[i][k] += set1[i][j]*set2[j][k] ;
}
}
cout<<"The resulting 3X4 matrix is :\n" ;
for (i=0 ; i<3 ; i++)
{
for (j=0 ; j<4 ; j++)
cout<<multi[i][j]<<"\t";
cout <<"\n" ;
}
getch ( ) ;
}
0 comments:
Post a Comment