
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ Program to Find Transpose of a Graph Matrix
In this program we take a matrix and prints the transpose of the matrix. In a transpose matrix, rows become columns and vice versa.
Algorithm
Begin Take number of rows and columns of the matrix. Take The elements of the matrix and stored in the matrix ‘A’. The transpose matrix is found by exchanging the rows with columns and columns with rows. Print both the original matrix and the transpose. End.
Example Code
#include<iostream> using namespace std; int main () { int A[10][10], a, b, i, j; cout << "Enter rows and columns of matrix : "; cin >> a>> b; cout << "Enter elements of matrix : "; for (i = 0; i < a; i++) for (j = 0; j < b; j++) cin >> A[i][j]; cout << "Entered Matrix : \n "; for (i = 0; i < a; i++) { for (j = 0; j < b; j++) cout << A[i][j] << " "; cout << "\n "; } cout << "Transpose of Matrix : \n "; for (i = 0; i < b;) { for (j = 0; j < a; j++) cout << A[j][i] << " "; cout << "\n "; } return 0; }
Output
Enter rows and columns of matrix:3 3 Enter elements of matrix : 6 7 1 3 2 5 9 12 11 Entered Matrix : 6 7 1 3 2 5 9 12 11 Transpose of Matrix : 6 3 9 7 2 12 1 5 11
- Related Articles
- C++ Program to Find Transpose of a Matrix
- Java Program to Find Transpose of a Matrix
- Python Program to find the transpose of a matrix
- Golang Program To Find The Transpose Of A Matrix
- Find the transpose of a matrix in Python Program
- Java program to transpose a matrix.
- Program to find the transpose of given matrix in Python
- Java program to print the transpose of a matrix
- C++ Program to Find Inverse of a Graph Matrix
- How to calculate transpose of a matrix using C program?
- Transpose a matrix in Java
- Transpose a matrix in Python?
- Transpose a matrix in C#
- How to Transpose a Matrix using Python?
- Golang Program To Find The Transpose

Advertisements