Symmetric Matrices

int row1,column1;
cout<<"Enter The Number of Rows:";
cin>>row1;
cout<<"Enter The Number of Columns:";
cin>>column1;

int matrix[row1][column1];
int i,j;

cout<<endl<<"Enter The First Matrix"<<endl;
for( i=0;i<row1;i++)
for( j=0;j<column1;j++)
cin>>matrix[i][j];

int row2,column2;
column2=row1;
row2=column1;

for( i=0;i<row2;i++)
{cout<<endl;
for( j=0;j<column2;j++)
{
cout<<matrix[j][i]<<" ";
}
}
cout<<endl;

if(matrix[j][i]==matrix[i][j]&& i==j)
cout<<"Symetric Matrix"<<endl;
else
cout<<"Not Symetric Matrix"<<endl;

plz this program to check symmetric of matrix it work well when columns != rows
but when columns = rows it cout symmetric although it is not symmetric
help me
Please use [code] tags.

The section:
1
2
3
4
  if(matrix[j][i]==matrix[i][j]&& i==j)
    cout<<"Symetric Matrix"<<endl;
  else
    cout<<"Not Symetric Matrix"<<endl;

cannot check the entire array. You have to make a loop, and only draw conclusions at the appropriate time. Here is a hint: try to prove that the matrix is not symmetric. If you cannot do that before looping through the entire matrix, then it must be symmetric.

Oh, also, the clause i==j is unnecessary.

Hope this helps.
Last edited on
i got the message mathemtical but i cant understand what i should write in the prog
plz give some help in writing code ?
You would loop through the matrices the same way you would looped through them to add data to them.
Topic archived. No new replies allowed.