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

A square matrix A is said to be skew-symmetric if Aij = −Aji for all i and j. In other words, a matrix A is skew-symmetric if the transpose of matrix A equals the negative of matrix A (AT = −A).

Note that all main diagonal elements in a skew-symmetric matrix are zero.

Syntax

// Check if matrix[i][j] == -matrix[j][i] for all i, j
if (A[i][j] == -A[j][i]) {
    // Matrix is skew-symmetric
}

Example Matrix

Let's take an example of a 3×3 matrix −

A = |0  -5   4|
    |5   0  -1|
    |-4  1   0|

This is a skew-symmetric matrix because Aij = −Aji for all i and j. For example, A12 = -5 and A21 = 5, which means A12 = −A21.

Original Matrix A: 0 -5 4 5 0 -1 -4 1 0 Transpose AT: 0 5 -4 -5 0 1 4 -1 0 We can see that AT = -A

Example: C Program to Check Skew-Symmetric Matrix

#include <stdio.h>

int main() {
    int A[10][10], i, j, m, n;
    int isSymmetric = 1, isSkewSymmetric = 1;
    
    printf("Enter the number of rows and columns: ");
    scanf("%d %d", &m, &n);
    
    // Check if matrix is square
    if (m != n) {
        printf("Matrix must be square for symmetry check.<br>");
        return 1;
    }
    
    printf("Enter the matrix elements:<br>");
    for (i = 0; i < m; i++) {
        for (j = 0; j < n; j++) {
            scanf("%d", &A[i][j]);
        }
    }
    
    // Check for symmetric and skew-symmetric properties
    for (i = 0; i < m; i++) {
        for (j = 0; j < n; j++) {
            if (A[i][j] != A[j][i]) {
                isSymmetric = 0;
            }
            if (A[i][j] != -A[j][i]) {
                isSkewSymmetric = 0;
            }
        }
    }
    
    // Display the matrix
    printf("\nMatrix:<br>");
    for (i = 0; i < m; i++) {
        for (j = 0; j < n; j++) {
            printf("%d ", A[i][j]);
        }
        printf("<br>");
    }
    
    // Display result
    if (isSkewSymmetric) {
        printf("\nThe matrix is skew-symmetric.<br>");
    } else if (isSymmetric) {
        printf("\nThe matrix is symmetric.<br>");
    } else {
        printf("\nThe matrix is neither symmetric nor skew-symmetric.<br>");
    }
    
    return 0;
}
Enter the number of rows and columns: 3 3
Enter the matrix elements:
0 -5 4
5 0 -1
-4 1 0

Matrix:
0 -5 4 
5 0 -1 
-4 1 0 

The matrix is skew-symmetric.

Key Properties

  • All diagonal elements of a skew-symmetric matrix are zero (Aii = 0)
  • The matrix must be square (m = n) to check for skew-symmetry
  • For skew-symmetric: Aij = −Aji for all i, j
  • The transpose of a skew-symmetric matrix equals its negative: AT = −A

Conclusion

A skew-symmetric matrix is characterized by the condition Aij = −Aji, making its transpose equal to its negative. This program efficiently checks this property by comparing corresponding elements across the main diagonal.

Updated on: 2026-03-15T11:43:49+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements