CJCoding With Joseph
15free / daySign inCreate account

Rotate Array Right by One

The program reads an integer n, then reads n integers into an array. Rotate the array one position to the right (the last element moves to the front) and print the result on one line, space-separated with no trailing space.

For the input 5 followed by 1 2 3 4 5, print the output shown in Expected Output.

End the line with a newline.

Expected Output:

5 1 2 3 4

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Arrays
📥 Auto-Input:
5\n1 2 3 4 5\n
This input is automatically fed to your program's stdin
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.