Home > C Examples > write a program to find a square matrix is symmetric.

write a program to find a square matrix is symmetric.

#include<stdio.h>
main()
{ int i,j,a[10][10],b[10][10],n,temp;
printf("\nEnter the dimensions of matrix:: ");
scanf("%d",&n);
printf("\nEnter the eleents of matrix::\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);

printf("\nOriginal Matrix is:: ");
for(i=0;i<n;i++)
{ printf("\n");
for(j=0;j<n;j++)
printf("\t%d",a[i][j]);
}

for(i=0;i<n;i++)
for(j=0;j<n;j++)
{b[j][i]=a[i][j];
}

printf("\nTranspose Matrix is:: ");
for(i=0;i<n;i++)
{ printf("\n");
for(j=0;j<n;j++)
printf("\t%d",b[i][j]);
}

for(i=0;i<n;i++)
{ for(j=0;j<n;j++)
{if(a[i][j]!=b[i][j])
{ printf("\nMatrix is not symmatric  :(\n");
exit(0);
}
}
}
printf("\nMatrix is symmatric  :)\n");
}
About these ads
  1. July 29, 2010 at 3:08 AM

    Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Journey to SQL Authority with Pinal Dave

SQL, SQL Server, MySQL, Big Data and NoSQL

Bug: An elusive creature living in a program that makes it incorrect. The activity of "debugging", or removing bugs from a program, ends when people get tired of doing it, not when the bugs are removed.

CodeProject Latest Articles

Bug: An elusive creature living in a program that makes it incorrect. The activity of "debugging", or removing bugs from a program, ends when people get tired of doing it, not when the bugs are removed.

Follow

Get every new post delivered to your Inbox.

Join 31 other followers

%d bloggers like this: