Arrays introduction C++ HackerRank solution

• Updated July 5, 2022

A series of elements can be used in a lot of conditions where it can come in handy to solve problems by iterating through a series of variables. This tutorial will help you with Arrays introduction C++ HackerRank solution.

arrays introduction c++ hackerrank solution

Problem statement

An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier…

You can check out the complete problem on Arrays introduction at HackerRank.

Also Read: Hackerrank problem on for loop


It first takes a variable named ‘n’ which holds the length of the array, later it runs ‘for loop’ respectively to take input of the array and to print the array by iterating through the loop.

#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    int arr[n];

    for(int i=0; i<n; i++){
        cin >> arr[i];

    for(int j=n; j>0; j--){
        cout << arr[j-1] <<" ";
    return 0;
Sharing Is Caring:

An aspiring BTech Electronics and Communication student, obsessed with Coding, Gadgets, and Blogging.

Leave a Comment