Thread: problem in Program to find Transpose of Given Square Matrix

1. problem in Program to find Transpose of Given Square Matrix

hi .I want to find transpos of square matrix.but my program does not run complete.I think there is some problem.can you help me?
Code:
```

#include<iostream>
using namespace std;
const int size=3;
{
cout<<"enter"<<size*size<<numbers<<endl;                                 for(int i=0;i<size;i++){
cout<< "row"<<i<<":";
for(int j=0;j<size;j++)
cin>>a[i][j];
}}
void trans(int at[size][size],int a[size][size])
{
int i,j;
for(int i=0;i<size;i++){
for(int j=0;j<size;j++)
at[i][j]=a[j][i];
cout<<at[i][j];
cout<<endl;
}}
int main()
{
int a[3][3],at[3][3];
trans(a,at);
trans(a,at);
return 0;
}```

http://sourceforge.net/apps/mediawik...le=Indentation

hi .I want to find transpos of square matrix.but my program does not run complete.I think there is some problem.can you help me?
Code:
```

#include<iostream>
using namespace std;
const int size=3;
{
cout<<"enter"<<size*size<<numbers<<endl;                                 for(int i=0;i<size;i++){
cout<< "row"<<i<<":";
for(int j=0;j<size;j++)
cin>>a[i][j];
}}
void trans(int at[size][size],int a[size][size])
{
int i,j;
for(int i=0;i<size;i++){
for(int j=0;j<size;j++)
at[i][j]=a[j][i];
cout<<at[i][j];
cout<<endl;
}}
int main()
{
int a[3][3],at[3][3];
trans(a,at);
trans(a,at);
return 0;
}```
It seems you tried to add "numbers" as a string literal but accidentally added it in as a variable with no initialisation and hence the compiler complains.

I think what you tried to do was the following; it works now; but this time it doesnt do what you want it to do:

Code:
```#include<iostream>
using namespace std;
const int size=3;

{
cout<<"enter"<<size*size<<" numbers"<<endl;
for(int i=0;i<size;i++){
cout<< "row"<<i<<":";
for(int j=0;j<size;j++)
cin>>a[i][j];
}
}

void trans(int at[size][size],int a[size][size])
{
int i,j;
for(int i=0;i<size;i++){
for(int j=0;j<size;j++)
at[i][j]=a[j][i];
cout<<at[i][j];
cout<<endl;
}
}

int main()
{
int a[3][3],at[3][3];