English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

C programming
2 D arrays

2006-09-30 00:22:08 · 2 answers · asked by Ricky 2 in Computers & Internet Programming & Design

2 answers

//to check if a 3x3 matrix is symmetric or not
#include
main()
{
int i,j,k=0,a[3][3];
clrscr();
printf("enter elements of 3x3 matrix");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}}
//to print the matrix as entered
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%3d",a[i][j]);
}
printf("\n");
}
//to check the symmetry
for(i=0;i<3;i++)
{
for(j=i;j<3;j++)
{
if(a[i][j]==a[j][i])
{
k++;
}}}
if(k==6)
printf("symmetric matrix");
else
printf("not symmetric");
getch();
}

[NOTE: u don't have to consider 2 matrices. Take 1 matrix as input, find its transpose. Now check if the original matrix & its transpose r same or not. If those 2 r same, then it'll give "symmetric" as output / otherwise, "not symmetric" as output.]

2006-09-30 00:35:52 · answer #1 · answered by Innocence Redefined 5 · 0 0

i can give u the link


http://www.inference.phy.cam.ac.uk/mackay/gallager/GH.html

2006-09-30 00:24:33 · answer #2 · answered by harsha 3 · 0 0

fedest.com, questions and answers