Question: 2. (20 points) Write a function Reverse() that creates and returns an array that contains reversed elements of an array. Following is the prototype of


2. (20 points) Write a function Reverse() that creates and returns an array that contains reversed elements of an array. Following is the prototype of the function: int* Reverse(int* arr, int size); The function receives two parameters: (1) an array of int, and (2) size of the array. The function returns a new dynamically allocated array whose elements are the reverse of arr. The size of the returned array must be the same to the size of arr. With your Reverse(), the following program int main() { int a[] = { 10, 30, 20, 15, 40, 50, 45 }; int size = sizeof(a) / sizeof(a[0]); // //int size = 7; int* revs = Reverse(a, size); cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
