CJCoding With Joseph
15free / daySign inCreate account

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 

= newline. No newline after the last line.

Hints4 available
Topics:
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.