# C Program To Check whether Matrix is Skew Symmetric or not

A Skew Symmetric Matrix or Anti-Symmetric Matrix is a square matrix whose transpose is negative to that of the original matrix. If the entry in the ith row and jth column of a matrix is a[i][j], i.e. if A = (a[i][j]) then the skew symmetric condition is -A = -a[j][i].

Example:

```Input : matrix:     0   5  -4
-5   0   1
4  -1   0

Output:
Transpose matrix:   0  -5   4
5   0   1
-4   1   0
Skew Symmetric matrix
```

Steps:

1. Find the transpose of the input matrix.
2. If the input matrix is equal to the negative of its transpose matrix, then the matrix is Skew Symmetrical.

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

```// C program to check whether given matrix
// is skew-symmetric or not
#include <stdio.h>
#include <stdlib.h>

#define ROW 3
#define COL 3

// Utility function to create transpose matrix
void transpose(int transpose_matrix[ROW][COL],
int matrix[ROW][COL])
{
for (int i = 0; i < ROW; i++)
for (int j = 0; j < COL; j++)
transpose_matrix[j][i] = matrix[i][j];
}

// Utility function to check skew - symmetric
// matrix condition
bool check(int transpose_matrix[ROW][COL],
int matrix[ROW][COL])
{
for (int i = 0; i < ROW; i++)
for (int j = 0; j < COL; j++)
if (matrix[i][j] != -transpose_matrix[i][j])
return false;
return true;
}

// Utility function to print a matrix
void printMatrix(int matrix[ROW][COL])
{
for (int i = 0; i < ROW; i++)
{
for (int j = 0; j < COL; j++)
printf("%d ", matrix[i][j]);
printf("\n");
}
}

// Driver program to test above functions
int main()
{
int matrix[ROW][COL] = {
{0, 5, -4},
{-5, 0, 1},
{4, -1, 0},
};

int transpose_matrix[ROW][COL];

// Function create transpose matrix
transpose(transpose_matrix, matrix);

printf ("Transpose matrix: \n");
printMatrix(transpose_matrix);

// Check whether matrix is skew-symmetric or not
if (check(transpose_matrix, matrix))
printf("Skew Symmetric Matrix");
else
printf("Not Skew Symmetric Matrix");

return 0;
}
```

Output:

```Transpose matrix:
0 -5 4
5 0 -1
-4 1 0
Skew Symmetric Matrix
```

References:
Wikipedia

This article is contributed by Akash Gupta. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

# GATE CS Corner    Company Wise Coding Practice

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.
1 Average Difficulty : 1/5.0
Based on 2 vote(s)