Thursday, 11 April 2013

C Program to find symmetric matrix


C Program to find symmetric matrix 

/*                                               Symmetric Matrix
   
                                              A  =  AT 

                   In other words the columns and rows of A are interchangeable */

 #include<stdio.h>
#include<conio.h>
main()
{
int a[10][10],at[10][10],k,i,j,m,n;
clrscr();
printf("enter the order of matrix");
scanf("%d %d",&m,&n);
printf("enter the matrix elements");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
at[i][j]=a[j][i];
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(at[i][j]!=a[i][j])
k=1;
}
}
if(k==1)
printf("not symmetric");
else
printf("symmetric");
getch();
}


SAMPLE OUTPUT:-

Enter the ordre of matrix

3
3
enter the matrix elements 
2
-1
0
-1
-2
3
0
3
4
symmetric

No comments: