C Program To Check whether Matrix is Skew Symmetric or not | C program to check whether given matrix is skew - symmetric or not ; Utility function to create transpose matrix ; Utility function to check skew - symmetric matrix condition ; Utility function to print a matrix ; Driver program to test above functions ; Function create transpose matrix ; Check whether matrix is skew - symmetric or not
#include <stdio.h> NEW_LINE #include <stdlib.h> NEW_LINE #define ROW  3 NEW_LINE #define COL  3 NEW_LINE 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 ] ; } 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 ; } 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 ( " STRNEWLINE " ) ; } } int main ( ) { int matrix [ ROW ] [ COL ] = { { 0 , 5 , -4 } , { -5 , 0 , 1 } , { 4 , -1 , 0 } , } ; int transpose_matrix [ ROW ] [ COL ] ; transpose ( transpose_matrix , matrix ) ; printf ( " Transpose ▁ matrix : ▁ STRNEWLINE " ) ; printMatrix ( transpose_matrix ) ; if ( check ( transpose_matrix , matrix ) ) printf ( " Skew ▁ Symmetric ▁ Matrix " ) ; else printf ( " Not ▁ Skew ▁ Symmetric ▁ Matrix " ) ; return 0 ; }