This C++ program displays the transpose of a graph matrix
Here is the source code of the C++ program to display the augmented matrix along with the inverse of the matrix taken as input. This C++ program is successfully compiled and run on DevCpp, a C++ compiler. The program output is given below.
/*
* C++ Program to Find Transpose of a Graph Matrix
*/
#include<iostream>
#include<conio.h>
#include<stdio.h>
using namespace std;
int main()
{
int i, j, n;
int a[10][10] = {0},b[10][10] = {0};
cout<<"Enter the order of matrix ";
cin>>n;
cout<<"Enter the elements\n";
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
cin>>a[i][j];
}
}
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
b[j][i] = a[i][j];
}
}
cout<<endl<<"Original Matrix\n";
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
cout<<endl<<"Transpose Matrix\n";
for (i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
cout<<b[i][j]<<" ";
}
cout<<endl;
}
getch();
}
Output Enter the order of matrix 3 Enter the elements 5 3 1 8 6 9 4 7 0 Original Matrix 5 3 1 8 6 9 4 7 0 Transpose Matrix 5 8 4 3 6 7 1 9 0
Sanfoundry Global Education & Learning Series – 1000 C++ Programs.
advertisement
If you wish to look at all C++ Programming examples, go to C++ Programs.
Related Posts:
- Practice Programming MCQs
- Check Data Structure Books
- Check Computer Science Books
- Apply for Computer Science Internship
- Check Programming Books