PropellerAds
Posted by : Unknown 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

PropellerAds
PropellerAds

Popular Post

Powered by Blogger.

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