← Back to Arrays
Question 426
Rotate Array Right by One
Rotate Array Right by One
The program reads an integern, then readsnintegers 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 input5followed by1 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
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.