Funky ChessBoard

Can you pls help me resolve why am i not getting correct ans and how should I modify my code ?

IDE : https://ide.codingblocks.com/s/192636

Hello @aman_ishan,

Why have you written your code in java?
I am a TA for C++ batch.

Please, report this to [email protected] if you have opted java.

Now, coming back to your code:

  1. The possible moves for a knight are:
    (r-2,c-1), (r-2,c+1), (r-1,c-2), (r-1,c+2), (r+1,c-2), (r+1,c+2), (r+2,c-1), or (r+2,c+1)
    But, in your code:
    for(a=0;a<8;a++)
    for(b=0;b<8;b++)
    You are iterating for 8x8=64 moves.

  2. There is no use of putting the following statements inside the loops:
    grid[i][j]=0; and grid[i][j]=1;

Hope, this would help.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.