# WAP in C to find if a square matrix is symmetric

The Program in C to find if a square matrix is symmetric is given below:

``````#include <stdio.h>

int main() {
int n;
printf("Enter the size of the square matrix: ");
scanf("%d", &n);

int matrix[n][n];
printf("Enter the elements of the matrix: \n");
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
scanf("%d", &matrix[i][j]);
}
}

int symmetric = 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (matrix[i][j] != matrix[j][i]) {
symmetric = 0;
break;
}
}
}

if (symmetric) {
printf("The matrix is symmetric.\n");
} else {
printf("The matrix is not symmetric.\n");
}

return 0;
}
``````

## Output:

Enter the size of the square matrix: 4
Enter the elements of the matrix:
12
34
66
32
78
99
45
65
43
32
12
34
55
43
34
55
The matrix is not symmetric.

## Pro-Tips💡

This program prompts the user to enter the size of a square matrix, and then the elements of the matrix.

It then checks if the matrix is symmetric by comparing each element in the matrix to its corresponding element in the transpose.

If all elements match, the matrix is symmetric, and the program prints “The matrix is symmetric.”

If any elements do not match, the matrix is not symmetric, and the program prints “The matrix is not symmetric.”

### Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

### Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

### Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

## C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

## C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

## C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

## C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

## C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

## C# Program to Delete Element at Desired position From Array

The Program in C# Program to Delete Element at Desired position From Array is given below: Output: Hello Codeauri Family, enter the number of elements in the array:4Enter…

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X