CJCoding With Joseph
15free / daySign inCreate account

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
Topics:
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.