I am trying to test the basic functioning of init(), but for some reason I am finding that for certain elements in the array, I am either missing a value or a value is doubled. Please help me understand what is causing this. If I place a printf function underneath the line where 'y' is decremented, the array prints as it is supposed to. However, if I attempt to print out individual values outside of the loops, I get some incorrect values. For instance, board[0][3] prints out 11, as does board[1][0]. Everything else prints as it should.
int row, col, d = 4, y = (d*d-1), board [d-1][d-1];
for (row = 0; row < d; row++)
{
for (col = 0; col < d; col++)
{
board[row][col] = y;
y--;
}
}