#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],n,m,n1,m1;
int i,j,s=0,k;
printf("Enter the order of the matrix=");
scanf("%d%d",&m,&n);
printf("\n Enter the elements of the matrix=\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{ printf("a[%d][%d]=",i,j);
scanf("%d",&a[i][j]);
}
}
printf("\n The Given matrix is=\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("\t%d",a[i][j]);
}
printf("\n");
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
b[j][i]=a[i][j];
}
}
printf("\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
printf("\t%d",b[i][j]);
}
printf("\n");
}
if ( m == n ) /* check if order is same */
{
for ( i = 0 ; i < m ; i++ )
{
for ( j = 0 ; j < m ; j++ )
{
if (a[i][j] != b[i][j] )
break;
}
if ( j != m )
break;
}
if ( i == m )
printf("Symmetric matrix.\n");
}
else
printf("Not a symmetric matrix.\n");
getch();
}
NEXT INPUT
#include<conio.h>
void main()
{
int a[3][3],b[3][3],n,m,n1,m1;
int i,j,s=0,k;
printf("Enter the order of the matrix=");
scanf("%d%d",&m,&n);
printf("\n Enter the elements of the matrix=\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{ printf("a[%d][%d]=",i,j);
scanf("%d",&a[i][j]);
}
}
printf("\n The Given matrix is=\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("\t%d",a[i][j]);
}
printf("\n");
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
b[j][i]=a[i][j];
}
}
printf("\n");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
printf("\t%d",b[i][j]);
}
printf("\n");
}
if ( m == n ) /* check if order is same */
{
for ( i = 0 ; i < m ; i++ )
{
for ( j = 0 ; j < m ; j++ )
{
if (a[i][j] != b[i][j] )
break;
}
if ( j != m )
break;
}
if ( i == m )
printf("Symmetric matrix.\n");
}
else
printf("Not a symmetric matrix.\n");
getch();
}
NEXT INPUT
No comments:
Post a Comment