We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. C++
  3. Introduction
  4. Arrays Introduction
  5. Discussions

Arrays Introduction

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • vm097363
    4 months ago+ 1 comment

    include

    include

    include

    include

    include

    using namespace std; void reversearrays(int arr[], int n) { int s = 0; int e = n - 1; while (s <= e) { swap(arr[s], arr[e]); s++; e--; }

    } void printarray(int arr[], int n) { for (int i = 0; i < n; i++) { cout << arr[i] << ' '; } }

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

    reversearrays(arr, n);
    cout << endl;
    cout << "Array elements after reversing " << endl;
    printarray(arr, n);
    return 0;
    

    }

    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy