Program for Identity Matrix | Program to print Identity Matrix ; Checking if row is equal to column ; Driver Code
function Identity ( num ) { var row ; var col ; for ( row = 0 ; row < num ; row ++ ) { for ( col = 0 ; col < num ; col ++ ) { if ( row == col ) document . write ( 1 + " " ) ; else document . write ( 0 + " " ) ; } document . write ( " " + " " ) ; } return 0 ; } size = 5 ; Identity ( size ) ;