144. C Program to Check the Symmetrix condition for the given Matrix.
How does this program work?
- In this C programme you will learn about how to check the symmetric condition for the given matrix.
- Here we used for loop condition to check the given symmetric condition.
Here is the code
//Intialize the variables
#include <stdio.h>
int main()
{
int m, n, c, d, matrix[10][10], transpose[10][10];
printf("Enter the number of rows and columns of matrix\n");
scanf("%d%d", &m, &n);
printf("Enter elements of the matrix\n");
//Store elements in array in Sequential order
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
scanf("%d", &matrix[c][d]);
for (c = 0; c < n; c++)
{
for(d = 0; d < m; d++)
printf("%d\t", matrix[c][d]);
printf("\n");
}
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
transpose[d][c] = matrix[c][d];
if (m == n) //Check oder is same or not
{
for (c = 0; c < m; c++)
{
for (d = 0; d < m; d++)
{
if (matrix[c][d] != transpose[c][d])
break;
}
if (d != m)
break;
}
if (c == m)
printf("The matrix is symmetric.\n");
else
printf("The matrix isn't symmetric.\n");
}
else
printf("The matrix isn't symmetric.\n");
return 0;
}