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 Code ; Function create transpose matrix ; Check whether matrix is skew - symmetric or not
using System ; class GFG { static int ROW = 3 ; static int COL = 3 ; static void transpose ( int [ , ] transpose_matrix , int [ , ] matrix ) { for ( int i = 0 ; i < ROW ; i ++ ) for ( int j = 0 ; j < COL ; j ++ ) transpose_matrix [ j , i ] = matrix [ i , j ] ; } static bool check ( int [ , ] transpose_matrix , int [ , ] matrix ) { 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 ; } static void printMatrix ( int [ , ] matrix ) { for ( int i = 0 ; i < ROW ; i ++ ) { for ( int j = 0 ; j < COL ; j ++ ) Console . Write ( matrix [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( ) { int [ , ] matrix = { { 0 , 5 , - 4 } , { - 5 , 0 , 1 } , { 4 , - 1 , 0 } , } ; int [ , ] transpose_matrix = new int [ ROW , COL ] ; transpose ( transpose_matrix , matrix ) ; Console . WriteLine ( " Transpose ▁ matrix : ▁ " ) ; printMatrix ( transpose_matrix ) ; if ( check ( transpose_matrix , matrix ) ) Console . WriteLine ( " Skew ▁ Symmetric ▁ Matrix " ) ; else Console . WriteLine ( " Not ▁ Skew ▁ Symmetric ▁ Matrix " ) ; } }