From c87fde91e92cadd9d131e64832c336237a545fad Mon Sep 17 00:00:00 2001 From: Azad Singh <71605755+azadhash@users.noreply.github.com> Date: Mon, 25 Oct 2021 08:30:00 +0530 Subject: [PATCH] Create Reversearray.cpp created a program to reverse a array --- ReverseArray.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 ReverseArray.cpp diff --git a/ReverseArray.cpp b/ReverseArray.cpp new file mode 100644 index 0000000..b4987e6 --- /dev/null +++ b/ReverseArray.cpp @@ -0,0 +1,37 @@ +#include +using namespace std; + + +void Reverse(int arr[], int start, int end) +{ + + while (start < end) + { + int temp = arr[start]; + arr[start] = arr[end]; + arr[end] = temp; + start++; + end--; + } +} + + +int main() +{ + int n; + cout << "Enter the size of the array: " << endl; + cin >> n; + int arr[n]; + cout << "Enter the array element: " << endl; + for (int i = 0; i < n; i++) + { + cin >> arr[i]; + } + Reverse(arr, 0, n - 1); + cout << "the reverse array is" << endl; + for(int j = 0; j