PROGRAM TO PERFORM MULTIPLICATION OF TWO MATRICES

//PROGRAM TO PERFORM MULTIPLICATION OF TWO MATRICES
class Multiplication
{
int[ ][ ] a={{1,2,3,4},{2,3,4,5}};
int[ ][ ] b={{1,1},{4,5},{3,4},{2,8}};
int[ ][ ] c={{0,0},{0,0}};
int i,j,k;
void calculate( )
{
for(i=0;i<2;i++)
{
for(k=0;k<2;k++)
{
for(j=0;j<4;j++)
{
c[i][k]=c[i][k]+a[i][j]*b[j][k];
}
}
}
}
void show( )
{
System.out.println(“Multiplication of two matrices is: “);

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
System.out.print(” “+c[i][j]);
}
System.out.println( );
}
}
}
class Execute
{
public static void main(String s[ ])
{
Multiplication m= new Multiplication( );
m.calculate( );
m.show( );
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *