To reverse an array, hackerrank problem solving question for array data structure, the following solutions uses time complexity of O(n).

#include<iostream>

using namespace std;

void reverseArray(int array[], int start, int end){
  
  while(start < end) {
    
    int temp = array[start];
    array[start] = array[end];
    array[end] = temp;
    start++;
    end--;
  
  }
 
}

void printArray(int array[], int arraySize){
    
    for(int i=0; i<arraySize; i++){
      cout<<array[i]<< " ";
    }
  
}

int main(){

  int arraySize;
  cout<<"Enter the size of the array ";
  cin>>arraySize;
  int array[arraySize];
  
  
  for(int i = 0; i<arraySize; i++){
    cout << "Enter the value in array ";
    cin >> array[i];
  }
  
  reverseArray(array, 0, arraySize-1);
  
  cout<<"The reversed array is ";
  
  printArray(array, arraySize);
  
  return 0;
}