/* Puzzle D33 -- shift every array element one position to the right */
/* element 0 gets 0, the original last element is lost */
void shiftRightArray( int size, int arr[] )
{
int j;
for ( j=size-1; j>=1; j-- )
arr[j] = arr[j-1];
arr[0] = 0;
}
Comments: You need to be careful to start 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.