![]() |
VOOZH | about |
Reversing an array is a common problem in programming where the task is to reorder the elements of the array so that the first element becomes the last, the second element becomes the second last, and so on.
Example:
Input: arr[] = {10, 20, 30, 40, 50}
Output: 50 40 30 20 10
To reverse an array using pointers, we can use two pointer approach: one pointing to the start of the array and other pointing to the end of the array while swapping the values at these pointers and moving the start pointer forward and the end pointer backward until pointers meet each other.
50 40 30 20 10