- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to transpose a matrix.
Following is the required program.
Example
public class Tester { public static void main(String args[]) { int a[][] = { { 1, 3, 4 }, { 2, 4, 3 }, { 3, 4, 5 } }; int t[][] = new int[3][3]; // transpose the matrix for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { t[i][j] = a[j][i]; } } System.out.println("Original Matrix:"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print(a[i][j] + " "); } System.out.println(); } System.out.println("Transposed Matrix:"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { System.out.print(t[i][j] + " "); } System.out.println(); } } }
Output
Original Matrix: 1 3 4 2 4 3 3 4 5 Transposed Matrix: 1 2 3 3 4 4 4 3 5
- Related Articles
- Java Program to Find Transpose of a Matrix
- Java program to print the transpose of a matrix
- Transpose a matrix in Java
- C++ Program to Find Transpose of a Matrix
- C++ Program to Find Transpose of a Graph Matrix
- Python Program to find the transpose of a matrix
- Golang Program To Find The Transpose Of A Matrix
- How to calculate transpose of a matrix using C program?
- Find the transpose of a matrix in Python Program
- Transpose a matrix in C#
- Transpose a matrix in Python?
- How to Transpose a Matrix using Python?
- Program to find the transpose of given matrix in Python
- How to Transpose a matrix in Single line in Python?
- Compute a matrix transpose with Einstein summation convention in Python

Advertisements