-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmatrix_symmetric.c
47 lines (40 loc) · 972 Bytes
/
matrix_symmetric.c
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
43
44
45
46
47
// [check whether matrix is symmetric or not]
/*
#include<stdio.h>
int main() {
int a[5][5], transpose[5][5],m, n, i, j;
printf("Enter number of rows and columns of matrix:\n");
scanf(" %d %d", &m, &n);
printf("Enter elements of matrix:\n");
for (i = 0; i < m; ++i)
{
for (j = 0; j < n; ++j)
{
scanf(" %d", &a[i][j]);
}
}
for (i = 0; i < m; ++i)
for (j = 0; j < n; ++j)
transpose[j][i] = a[i][j];
if(m == n)
{
for (i = 0; i < m; ++i)
{
for (j = 0; j < n; ++j)
{
if (a[i][j] != transpose[i][j])
break;
}
if (j == m)
break;
}
if (j == m)
printf("The matrix is symmetric.\n");
else
printf("The matrix is not symmetric.\n");
}
else
printf("The matrix is not symmetric.\n");
return 0;
}
*/