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