Skip to content

Commit

Permalink
reverse array
Browse files Browse the repository at this point in the history
  • Loading branch information
AdithyakrishnaV committed Sep 23, 2021
1 parent 2846c38 commit c3416f6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions reverse_array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <bits/stdc++.h>
using namespace std;

int main(){
int n;
cin>>n;
int arr[n];

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

for(int i=0;i<n;i++){
cout<<arr[i];
}
cout<<"\n";
int l=0, h=n-1;

while(l<h){
int temp=arr[l];
arr[l]=arr[h];
arr[h]=temp;
l++;
h--;
}

for(int i=0;i<n;i++){
cout<<arr[i];
}
cout<<"\n";

return 0;
}

0 comments on commit c3416f6

Please sign in to comment.