CJCoding With Joseph
15free / daySign inCreate account

Print in Reverse Order

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

Your task is to print all elements in reverse order, each on its own line. That means the last element prints first, and the first element prints last.

To do this, you need a for loop that starts at the last index (4) and counts down to 0. The loop should look like:
for (int i = 4; i >= 0; i--)

The key difference from a normal loop is that i starts high and decreases with i-- instead of i++.

Expected Output:

50
40
30
20
10

= newline. No newline after the last line.

Hints2 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.