 # Program to find if a 3 by 3 square matrix is symmetric

A symmetric matrix is a square matrix that is equal to its transpose. Let A be a symmetric matrix.
Then,
A = AT

In this program, we need to check whether the given square matrix is symmetric or not. We will follow the steps given below.

• Step 1 – Accepts a square matrix as input
• Step 2 – Create a transpose of a matrix and store it in an array
• Step 3 – Check if input matrix is equal to its transpose or not
If it is equal, then the input square matrix is symmetric.

Here it goes…

```#include
#include

void main(){
int arr, arrT;
int i,j;
clrscr();
printf("Enter the 3x3 matrix:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("Enter the element arr[%d][%d] : ",i,j);
scanf("%d",&arr[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
arrT[j][i] = arr[i][j];
}
}

for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(arr[i][j] == arrT[i][j]){
continue;
}
else{
printf("\nInput matrix is not a symmetric matrix.");
getch();
exit(0);
}
}
}
printf("\nInput matrix is a symmetric matrix");
getch();
}```

Output:

```Enter the 3x3 matrix:
Enter the element arr : 1
Enter the element arr : 2
Enter the element arr : 3
Enter the element arr : 2
Enter the element arr : 4
Enter the element arr : -5
Enter the element arr : 3
Enter the element arr : -5
Enter the element arr : 6

Input matrix is a symmetric matrix
```

### 14 Responses

1. Anonymous says:

Thanks a lot!!!!!!!!

2. Anonymous says:

thanks for the program really helpful!!! cheers!!!!

3. LearnCOnline says:

4. Anonymous says:

Thanks

5. Anonymous says:

i have a simple solution for this program

6. LearnCOnline says:

Thanks… Would be highly appreciated if you provide us with the solution.
Regards.

7. Anonymous says:

tht is else shud be in t same pair of braces

8. Anonymous says:

we can also do without taking transpose.
just write directly a[i][j]=a[j][i]..

9. Anonymous says:

thank you

10. Anonymous says:

it is very much helpfull to us

11. Anonymous says:

logic absolutely right….thank you…..

12. Anonymous says:

Thanks to explain this in such a delecate manner!

13. Anonymous says:

thanks

14. Anonymous says: 