C Program to check whether a Matrix is Symmetric or not

C Program to check whether a Matrix is Symmetric or not: A Square Matrix is said to be symmetric if it is equal to its transpose.Transpose of a matrix is achieved by exchanging indices of rows and columns.

C Program to check whether a Matrix is Symmetric or not

#include <stdio.h>
#define SIZE 3
int main()
{
    int A[SIZE][SIZE]; 
    int B[SIZE][SIZE]; 
    int row, col, isSymmetric;
    printf("Enter elements in matrix of size 3x3: \n");
    for(row=0; row<SIZE; row++)
    {
        for(col=0; col<SIZE; col++)
        {
            scanf("%d", &A[row][col]);
        }
    }

    for(row=0; row<SIZE; row++)
    {
        for(col=0; col<SIZE; col++)
        {
           
            B[row][col] = A[col][row];
        }
    }

    isSymmetric = 1;
    for(row=0; row<SIZE && isSymmetric; row++)
    {
        for(col=0; col<SIZE; col++)
        {
            if(A[row][col] != B[row][col])
            {
                isSymmetric = 0;
                break;
            }
        }
    }

    if(isSymmetric == 1)
    {
        printf("\nThe given matrix is Symmetric matrix: \n");

        for(row=0; row<SIZE; row++)
        {
            for(col=0; col<SIZE; col++)
            {
                printf("%d ", A[row][col]);
            }

            printf("\n");
        }
    }
    else
    {
        printf("\nThe given matrix is not Symmetric matrix.");
    }

    return 0;
}

Output of Program

Enter elements in matrix of size 3×3:
6
7
9
25
36
6
12
32
23

The given matrix is not Symmetric matrix.