Reverse an array(((()))))

MY one test case is failing…why??
#include
using namespace std;

void reversearr(int a[], int begin, int end)
{
while (end > begin)
{
int start = a[begin];
a[begin] = a[end];
a[end] = start;
begin++;
end–;
}
}

void printarr(int a[] , int n){
for (int i = 0; i < n; i++)
{
cout<<a[i];
}

}

int main()
{
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++)
{
cin>>a[i];
}
reversearr(a , 1 , n-1);
printarr(a , n);

return 0;

}

hi @abhinavssr2003_eab0717682969e5c,
this is not reverse array question, here Inverse is Simply swapping the value of the array with the value at that index.

Algo

  1. Create a new Array say narr and original array is arr.
  2. now at the arr[i]th index of narr save the ith value.(previously i is the index and arr[i] is the value bt now arr[i] is the index and i is the value.)
  3. print the array

check here there is some fault in online ide of cb so im sharing the pic of code

hi @abhinavssr2003_eab0717682969e5c
u can refer to the code ive commented https://ide.codingblocks.com/s/657727

sir please correct my code if you can as i am not familiar with strings yet

hi @abhinavssr2003_eab0717682969e5c,

corrected your code check this https://ideone.com/8lW4Vw

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.