100 Most Important C# Programs
62. Program to find whether a square matrix is a) symmetric b) skew symmetric c) none of two.
Code:
# include <stdio.h>
# include <conio.h>
main( )
{
int a[10][10],i,j,m,n,c=0,c1=0;
clrscr( );
printf(“enter the array size”);
scanf(“%d”,&n);
printf(“enter the elements”);
for(i=1;i<=m;i++)
for(j=1;j<=n;j++)
scanf(“%d”,&a[i][j]);
for(i=1;i<=m;i++)
for(j=1;j<=n;j++)
{
if(a[i][j]==a[j][i])
c=1;
else
if(a[i][j]==a[j][i])
c1=1;
}
printf(“the given matrix is \n”);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
printf(“%4d”,a[i][j]);
printf(“\n”);
}
if(c==0)
printf(“the given matrix is symmetric”);
else
if(c1==0)
printf(“the matrix is skew symmetric”);
else
printf(“none of two”);
}
getch( );
}