The array has 10 elements,with indexes from 0 to 9, but the last time round
the loop i = 9, and hence the code tries to do array[9] = array[10],
which would result in an error since a[10] does not exist.
The array index must always be an integer and hence the first line
should have been