Program for Identity Matrix | C # program to print Identity Matrix ; Checking if row is equal to column ; Driver Code
using System ; class GFG { static int identity ( int num ) { int row , col ; for ( row = 0 ; row < num ; row ++ ) { for ( col = 0 ; col < num ; col ++ ) { if ( row == col ) Console . Write ( 1 + " ▁ " ) ; else Console . Write ( 0 + " ▁ " ) ; } Console . WriteLine ( ) ; } return 0 ; } public static void Main ( ) { int size = 5 ; identity ( size ) ; } }