Reversing can also be done recursively by swapping the first and last elements and then calling the function again for the inner part of the array.
void reverse(int[] arr, int start, int end) { if (start >= end) return; int temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; reverse(arr, start + 1, end - 1);}The base case occurs when the two indices cross, meaning the array has been completely reversed.