← Back to Arrays
Question 225
Reverse an Array In Place
Reverse an Array In Place
Instead of just printing an array backwards, here you actually rearrange the array itself so its elements end up in reverse order. The trick is to swap the first element with the last, the second with the second-to-last, and so on, only going halfway (size / 2 swaps). Each swap needs a temporary variable to hold one value while you move the other. After reversing, print all elements separated by spaces, with no trailing space.
Expected Output:
60 50 40 30 20 10= newline. No newline 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 (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.