/* Puzzle C33 -- shift every array element one position to the right */ /* element 0 gets 0, the original last element is lost */ void shiftRightArray( int arr[], int size ) { int j; for ( j=size-1; j>=1; j-- ) arr[j] = arr[j-1]; arr[0] = 0; }
j
at the
right side of the array and count downwards. If you start j
out
at zero, you might end up copying element 0 upward to all other elements.