#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,temp,a[5][5],flag=0,b[5][5];
clrscr();
printf("Enter the order of the matrix::\n");
scanf("%d",&n);
printf("Enter the elements of the matrix::\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
b[i][j]=a[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
temp=a[i][j];
a[i][j]=a[j][i];
a[j][i]=temp;
}
}
printf("Transpose Matrix is::\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]!=b[i][j])
{
flag=1;
}
}
}
if(flag==1)
{
printf("The matrix is not symmetric.");
}
else
printf("Matrix is symmetric.");
getch();
}
#include<conio.h>
void main()
{
int n,i,j,temp,a[5][5],flag=0,b[5][5];
clrscr();
printf("Enter the order of the matrix::\n");
scanf("%d",&n);
printf("Enter the elements of the matrix::\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
b[i][j]=a[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
temp=a[i][j];
a[i][j]=a[j][i];
a[j][i]=temp;
}
}
printf("Transpose Matrix is::\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]!=b[i][j])
{
flag=1;
}
}
}
if(flag==1)
{
printf("The matrix is not symmetric.");
}
else
printf("Matrix is symmetric.");
getch();
}
No comments:
Post a Comment