Question bank › Matrix
Dsa Matrix Easy

Matrix Transpose

You are given a matrix of size m x n. Write a program to compute the transpose of the matrix. The transpose of a matrix is obtained by swapping its rows with its columns. Input Format: The first line contains two integers m and n (1 <= m, n <= 100). Each of the next m lines contains n space-separated integers representing the elements of the matrix. Output Format: Print the transposed matrix with each row on a new line and elements separated by space. Example: Input: 2 3 1 2 3 4 5 6 Output: 1 4 2 5 3 6

Key concepts

matrixtransposetransformation

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.