- Related Questions & Answers
- Find the transpose of a matrix in Python Program
- Program to find the transpose of given matrix in Python
- C++ Program to Find Transpose of a Matrix
- C++ Program to Find Transpose of a Graph Matrix
- Java program to print the transpose of a matrix
- Java program to transpose a matrix.
- Transpose a matrix in Python?
- How to Transpose a Matrix using Python?
- How to calculate transpose of a matrix using C program?
- Transpose a matrix in C#
- Transpose a matrix in Java
- How to Transpose a matrix in Single line in Python?
- A C++ Program for 2d matrix for taking Transpose
- Python Program to find out the determinant of a given special matrix
- Program to find diagonal sum of a matrix in Python

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this article, we will learn about the solution and approach to solve the given problem statement.

Given a matrix, we need to store the transpose in the same matrix and display it.

Transpose of a matrix is obtained by changing rows to columns and columns to rows. In other words, transpose of A matrix is obtained by changing A[i][j] to A[j][i].

Let’s see the implementation given below −

N = 4 def transpose(A): for i in range(N): for j in range(i+1, N): A[i][j], A[j][i] = A[j][i], A[i][j] # driver code A = [ [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]] transpose(A) print("Modified matrix is") for i in range(N): for j in range(N): print(A[i][j], " ", end='') print()

Modified matrix is 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4

All the variables and functions are declared in the global scope as shown below −

In this article, we learned about the approach to find the transpose of the given matrix.

Advertisements