×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Multiplication of two matrix - Java Program JAVA Practical Question ISC 2016 Solve - Circular Prime
Write a Java program to transpose of a matrix. - Java
3283    Arnab De    07/04/2019

Write a Java program to transpose of a matrix.

Read a matrix as a 2D array. Transpose of a matrix means convert all the rows into columns. Here we look the index of col and row are equal for the diagonal elements of the array. and also after transpose the diagonal elements are remain unchanged. Therefore, here we just exchanged the row elements with col elements with respect to the diagonal elements.

softetechnologies

import java.util.*;

class MatrixTranspose
{
	public static void main()
	{
		int arr1[3][3],i,j,temp;
		Scanner sc=new Scanner(System.in);
		System.out.println("Enter The Matrix Elements\n");
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				arr1[i][j]=sc.nextInt();
			}
		}	
		
		for(i=0;i<3;i++)
		{
			for(j=i+1;j<3;j++)
			{
				temp=arr1[i][j];
				arr1[i][j]=arr1[j][i];
				arr1[j][i]=temp;
			}
		}
		
		System.out.println("\nFinal array Elements\n");
		for(i=0;i<3;i++)
		{
			for(j=0;j<3;j++)
			{
				System.out.print(arr3[i][j] + "  ");
			}
			System.out.println("");
		}
	}
}
softetechnologies
Multiplication of two matrix - Java Program JAVA Practical Question ISC 2016 Solve - Circular Prime
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Swami Vivekananda
Fill the brain with high thoughts, highest idrals, place them day and night before you, and out of that will come great work.
Swami Vivekananda
2340
85.85
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     54907
25/06/2018     46035
01/01/2018     44178
28/06/2017     41749
02/08/2017     40828
01/08/2017     34839
06/07/2017     34592
15/05/2017     33801
11/09/2018     31487
14/07/2017     30704
softetechnologies