for (n, n<= size*size, n++) You sure you want to do this? Just a suggestion, but start with a 3X3 array to see if you have the code working properly