Write a function void switchEnds(int *array, int size); that is passed the address of the beginning of an array and the size of the array. The function swaps the values in the first and last entries of the array.
#include <iostream>
using namespace std;
void switchEnd(int *array, int size){
int temp=array[0];
array[0]=array[size-1];
array[size-1]=temp;
}
int main()
{ const int size=5;
int array[size]={1,2,3,4,5};
switchEnd(array,size);
for (int c=0;c<5;c++)
cout<<array[c]<<" ";
}