Menu
Coddy logo textTech

Reverse an Array

Lesson 15 of 26 in Coddy's Arrays in C++ course.

challenge icon

Challenge

Easy

Given an Array, print all the elements in reverse order separated by space.

For Example, if:

int arr[]={1,2,3};

Then the output should be:

3 2 1

Try it yourself

#include<iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
    //Write your code here 

    return 0;
}   

All lessons in Arrays in C++