PROGRAM TO FIND THE TRANSPOSE OF MATRIX

//PROGRAM TO FIND THE TRANSPOSE OF MATRIX
class Transpose
{
int a[ ][ ]={{1,2,3},{3,5,6}};
int b[ ][ ]={{0,0},{0,0},{0,0}};
int i,j;
void calculate( )
{
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
b[j][i]=a[i][j];
}
}
}
void display( )
{
System.out.println(“Transpose of matrix is: “);
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{

System.out.print(” “+b[i][j]);
}
System.out.println( );
}
}
}
class Test
{
public static void main(String args[ ])
{
Transpose t= new Transpose( );
t.calculate( );
t.display( );
}
}

Leave a Reply

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