Cranes at VIIT Q17

Shift Elements of an Array to the Right

Write a C program that shifts all the elements of an array one position to the right. The last element should move to the first position.

Example:

Original array: 1 2 3 4 5
Shifted array: 5 1 2 3 4
            

Task: Write a program that performs this right shift operation on an array of integers.

Hint: Store the last element of the array in a temporary variable. Then loop from the end to the beginning, shifting each element one position to the right. Finally, place the stored value at the first index.