From 2aa8b82405f1762cfb3e4c05d7580d4e339215c5 Mon Sep 17 00:00:00 2001 From: Vanshika Sisodiya <76210357+vanshika2217@users.noreply.github.com> Date: Wed, 6 Oct 2021 22:55:21 +0530 Subject: [PATCH] Create ReverseArray.cpp --- ReverseArray.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ReverseArray.cpp diff --git a/ReverseArray.cpp b/ReverseArray.cpp new file mode 100644 index 0000000..128c71a --- /dev/null +++ b/ReverseArray.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; + +int main() { + //to reverse an array + int n; + cout<<"Enter the size of an array: "<>n; + //declaring array + int ar[n]; + cout<<"Enter an array: "<>ar[i]; + } + int i=0; + int j=n-1; + while(i<=j){ + int temp; + temp=ar[i]; + ar[i]=ar[j]; + ar[j]=temp; + i++; + j--; + } + cout<<"Reverse array is: "<