Rewrite the following function using pointers Rewrite the fo
Rewrite the following function using pointers:
Rewrite the following function using pointers: void foo (int x[], int n) {int i, j, t; for (i = 0, j = n-1; iSolution
#include <iostream>
 #include<string.h>
 using namespace std;
void fooWithPointer(int x[],int n)
 {
     int i,j,t;
     for(i=0,j=n-1;i<j;i++,j--)
     {
         t = *(x+i);
         *(x+i) = *(x+j);
         *(x+j) = t;
     }
 }
void foo(int x[],int n)
 {
     int i,j,t;
     for(i=0,j=n-1;i<j;i++,j--)
     {
         t = x[i];
         x[i] = x[j];
         x[j] = t;
     }
 }
void printArray(int arr[],int size)
 {
     int i;
     for(i=0;i<size;i++)
         cout << arr[i] << \" \";
     cout << endl;
 }
int main ()  
 {
     int arr[] = {1,2,3,4,5};
     fooWithPointer(arr,5);
     printArray(arr,5);
     return 0;  
 }
![Rewrite the following function using pointers: Rewrite the following function using pointers: void foo (int x[], int n) {int i, j, t; for (i = 0, j = n-1; iSolu Rewrite the following function using pointers: Rewrite the following function using pointers: void foo (int x[], int n) {int i, j, t; for (i = 0, j = n-1; iSolu](/WebImages/10/rewrite-the-following-function-using-pointers-rewrite-the-fo-1002344-1761516446-0.webp)
