Java program to transpose a matrix

      No Comments on Java program to transpose a matrix

Transpose a matrix:-

This program illustrate the concept of transpose a matrix.

  • Matrix transpose is very simple.
  • Matrix transpose means changing rows into coloumns and coloumns into rows.
  • Here in this program i=number of rows.
  • And j=number of coloumns
import java.util.*;
class scan
{
 public static void main(String arg[])
  {
   int  a[][]=new int[3][3];
   int i,j;
   Scanner kb=new Scanner(System.in);
   
   System.out.println("Enter Matrice row wise:-");
 
 for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
    a[i][j]=kb.nextInt();
    }
  }
  System.out.println("Transpose of Matrice is:-\n");
  for(i=0;i<3;i++)
  {
   for(j=0;j<3;j++)
    {
   System.out.print(" "+a[j][i]);
 
    }
    System.out.println();
  }
  }
}

OUTPUT:-

transpose a matrix


Comment below if you are facing any problem.


Also read

java program to print a matrix in 2d array
How to add two matrix in java


Summary
Java program to transpose a matrix
Article Name
Java program to transpose a matrix
Description
This program illustrate the concept of transpose a matrix.Matrix transpose means chaning rows into coloumns and coloumns into rows.
Author
Publisher Name
Scanfcode
Publisher Logo

Leave a Reply

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