← Back to STL Containers
Question 537
Reverse a std::array In Place
Reverse a std::array In Place
Write a function void reverseArray(array<int, 5>& a) that reverses the order of the five elements inside the array itself (no return value, no second array).
The test calls your function and prints the elements separated by spaces on one line. For {1, 2, 3, 4, 5} it prints the output shown in Expected Output.
Do NOT write a main function.Expected Output:
5 4 3 2 1 3 0 1 7 7
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
STL Containersstd::array
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.