Question
Program to find the transpose of a given matrix
Matrix = [9, 8, 7]
[6, 5, 4]
[3, 2, 1]
TRANSPOSE
[9, 6, 3]
[8, 5, 2]
[7, 4, 1]
Share code with your friends
Share on whatsapp
Share on facebook
Share on twitter
Share on telegram
Code
import java.util.Scanner;
public class TransposeMatrix
{
public static void main(String[] args)
{
int row=0, col=0,i=0,j=0;
int a[][],t[][];
Scanner sc=new Scanner(System.in);
System.out.println("ENTER THE ROW OF MATRIX");
row=sc.nextInt();
System.out.println("ENTER THE COLUMN OF MATRIX");
col=sc.nextInt();
a=new int[row][col];
t=new int[row][col];
System.out.println("ENTER THE ELEMENTS IN MATRIX");
for(i=0;i< row;i++)
{
for(j=0;j< col;j++)
{
a[i][j]=sc.nextInt();
}
}
for(i=0;i< row;i++)
{
for(j=0;j< col;j++)
{
t[i][j]=a[j][i];
}
}
System.out.println("TRANSPOSE OF MATRIX: ");
for(i=0;i< row;i++)
{
for(j=0;j< col;j++)
{
System.out.print(t[i][j]);
}
System.out.println();
}
}
}
Coding Store
Sale

ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale

ICSE QUESTION PAPER WITH SOLUTION(PROGRAMMING ONLY)
Sale

ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale

ICSE QUESTION PAPER WITH SOLUTION(PROGRAMMING ONLY)
Sale

ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale
