Here is a C++ program to check whether a matrix is symmetric or not
SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
int a[10][10],temp,ord;
cout<<"Enter order of matrix (max 10*10): ";
cin>>ord;
cout<<"Enter matrix a1 : "<<endl;
for(int i=0;i<ord;i++)
for(int j=0;j<ord;j++)
cin>>a[i][j];
for(int i=0;i<ord;i++)
for(int j=0;j<ord;j++)
if(a[i][j]!=a[j][i])
{
cout<<"Matrix is not symmetric matrix ";
return 0;
}
cout<<"Matrix is symmetric";
return 0;
}
using namespace std;
int main()
{
int a[10][10],temp,ord;
cout<<"Enter order of matrix (max 10*10): ";
cin>>ord;
cout<<"Enter matrix a1 : "<<endl;
for(int i=0;i<ord;i++)
for(int j=0;j<ord;j++)
cin>>a[i][j];
for(int i=0;i<ord;i++)
for(int j=0;j<ord;j++)
if(a[i][j]!=a[j][i])
{
cout<<"Matrix is not symmetric matrix ";
return 0;
}
cout<<"Matrix is symmetric";
return 0;
}
Any questions regarding to program please write in comments.
maturely written code,,, :) thanks
ReplyDelete