# 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 = A^{T}

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[10][10], arrT[10][10]; 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[0][0] : 1 Enter the element arr[0][1] : 2 Enter the element arr[0][2] : 3 Enter the element arr[1][0] : 2 Enter the element arr[1][1] : 4 Enter the element arr[1][2] : -5 Enter the element arr[2][0] : 3 Enter the element arr[2][1] : -5 Enter the element arr[2][2] : 6 Input matrix is a symmetric matrix

Thanks a lot!!!!!!!!

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

You are welcome. You can follow us on http://www.facebook.com/pages/LearnCOnline/180905478591746

Thanks

i have a simple solution for this program

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

Regards.

tht is else shud be in t same pair of braces

we can also do without taking transpose.

just write directly a[i][j]=a[j][i]..

thank you

it is very much helpfull to us

logic absolutely right….thank you…..

Thanks to explain this in such a delecate manner!

thanks

your program is very easy