Check out example codes for "Arrays hackerrank solution in c++". It will help you in understanding the concepts better.

Code Example 1

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */  
    int n,i=0;
    cin>>n;
    int *a = new int[n];
    while(cin>>a[i++]);
    while(cout<<a[--n]<<' '&& n);
    delete[] a; 
    return 0;
}

Learn ReactJs, React Native from akashmittal.com