CJCoding With Joseph
15per day

Shift Elements Left

An array called nums has already been created for you with the values {10, 20, 30, 40, 50}.

Your task is to shift all elements one position to the left. The first element wraps around to the end.

Here's what should happen step by step:
1. Save the first element (10) in a temporary variable.
2. Move each element one position to the left: nums[0] = nums[1], nums[1] = nums[2], etc.
3. Put the saved value into the last position.

After shifting, the array should be {20, 30, 40, 50, 10}.

Print all elements on one line separated by spaces.

Expected output:
20 30 40 50 10 

Expected Output:

20 30 40 50 10 
Topics:
Arrays
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.