Andrew: Regarding int i,a[10]; for(i=0; i<=10; i++) a[i] = 0; you should have expected some problems, as you are writing one past the end of the array! The correct test to use is < not <=!