It looks like you are running the loop for one too many iterations. Because the array is [5][5] and you are using [r][c+1] you never want c to be 4.
change
for (int c = 0; c < gridCol; c++){
to
for (int c = 0; c < gridCol-1; c++){
and see if that works