#include<iostream>
using namespace std;
int main()
{
int n, m, i, j;
cout << "Enter Array Row & Column Number : ";
cin >> n >> m;
cout << endl;
int a[n][m], b[n][m];
cout << "Enter Array Element : \n";
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout << "a[" << i << "][" << j << "] = ";
cin >> a[i][j];
}
cout << endl;
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
b[i][j] = a[j][i];
}
}
cout << "\nTranspose of Matrix :: \n";
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout << b[i][j] << " ";
}
cout << endl;
}
return 0;
}
using namespace std;
int main()
{
int n, m, i, j;
cout << "Enter Array Row & Column Number : ";
cin >> n >> m;
cout << endl;
int a[n][m], b[n][m];
cout << "Enter Array Element : \n";
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout << "a[" << i << "][" << j << "] = ";
cin >> a[i][j];
}
cout << endl;
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
b[i][j] = a[j][i];
}
}
cout << "\nTranspose of Matrix :: \n";
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout << b[i][j] << " ";
}
cout << endl;
}
return 0;
}
Comments
Post a Comment