Rotate Array Right by One
mediumQuestion 426The 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, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
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.