luc065.c ​
Metadata ​
- Author — Amit Dutta
- Last updated — 08 Feb 2026
- License — MIT License (See the LICENSE file for details)
Problem Statement ​
Problem Statement
Write a program to find if a square matrix is symmetric.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
#include <stdlib.h>
int main()
{
int mat[10][10], n, i, j;
int is_symmetric = 1;
printf("Enter the size of the square matrix (max 10): ");
scanf("%d", &n);
printf("Enter elements of the %dx%d matrix:\n", n, n);
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
scanf("%d", &mat[i][j]);
}
}
// Check for symmetry: mat[i][j] must equal mat[j][i]
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
if (mat[i][j] != mat[j][i])
{
is_symmetric = 0;
break;
}
}
if (is_symmetric == 0)
break;
}
if (is_symmetric)
printf("\nThe matrix is Symmetric.\n");
else
printf("\nThe matrix is NOT Symmetric.\n");
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42