Posted by : Waqas Javed Thursday, 25 December 2014

This program demonstrate the conversion of matrix to its transpose using array and loops. For more detail on int, array, for loop and other basic commands see our other post on respective topic.

#include<iostream>
#include<conio.h>

using namespace std;

void main(){
int Matrix[50][50];
int transpose[50][50];

int x;
int y;

cout << "Enter No. of rows:";
cin >> x;

cout << "Enter No. of column:";
cin >> y;

for (int i = 0; i < x; i++){
for (int j = 0; j < y; j++){
cout << "please enter elements: ";
cin >> Matrix[i][j];
}
}

cout << "\nOrignal matrix:\n";

for (int i = 0; i < x; i++){
for (int j = 0; j < y; j++){
cout << Matrix[i][j] << '\t';
}

cout << endl;
}

for (int i = 0; i < x; i++){
for (int j = 0; j < y; j++){
transpose[j][i] = Matrix[i][j];
}
}

cout << "\nTranpose matrix:\n";

for (int i = 0; i < y; i++){
for (int j = 0; j < x; j++){
cout << transpose[i][j] << '\t';
}

cout << endl;
}

_getch();

}

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Contact Us

Stay updated for more codes if we u want any code write us by commenting below or email us.
If you want to hire us for your semester project email us at above given email or call or message
Email: 14bscswjaved@seecs.edu.pk
Phone no: 0308-8109708

Popular Post

Powered by Blogger.

- Copyright © BSCS -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -