CJCoding With Joseph

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:

5 1 2 3 4

End the line with a newline.

Expected Output:

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