CJCoding With Joseph
15free / daySign inCreate account

An array called nums has already been created for you with the values {10, 20, 30, 40, 50}.

Your task is to reverse the array in place (without creating a second array), then print all elements on one line separated by spaces.

To reverse an array in place, you swap elements from the outside in: - Swap nums[0] with nums[4] - Swap nums[1] with nums[3] - The middle element (nums[2]) stays where it is

You only need to loop through the first half of the array. For each index i, swap nums[i] with nums[4 - i].

Expected output

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 (cout, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.