Reverse an Array - I

You are given an array arr containing N integers.

Reverse the order of the elements in arr and print the reversed array.

Input

The input contains:

  • An integer N — the number of elements in the array arr.
  • N integers — the elements of arr.

Output

  • Print the elements of arr in reverse order, separated by spaces.

Example 1:

Input:

5
1 2 3 4 5

Output:

5 4 3 2 1

Explanation:

The reverse of the array [1,2,3,4,5] is [5,4,3,2,1]

Example 2:

Input: 

4
10 20 30 40

Output:

40 30 20 10

Explanation:

The reverse of the array [10,20,30,40] is [40,30,20,10].

Now Your Turn!

Pick the correct output for the given input

Input: 

3
3 2 1

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= n <= 100
  • -1000 <= arr[i] <= 1000

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
// Your code goes here
}
Test Case
Input