Function returns true if the move taken is valid else it will return false .
static bool isSafe ( int row , int col , int [ , ] m , int n , bool [ , ] visited ) { if ( row == - 1 row == n col == - 1 col == visited [ row , col ] m [ row , col ] == 0 ) return false ; return true ; }