Question
// Chapter 9, Programming Challenge 10: Reverse Array #include using namespace std; // Prototype int *reverseArray(int[], int); void showArray(int[], int); int main() { const int
// Chapter 9, Programming Challenge 10: Reverse Array #include using namespace std; // Prototype int *reverseArray(int[], int); void showArray(int[], int); int main() { const int SIZE = 10; int values[SIZE] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // TODO: Display the contents of the array. // TODO: Make a reverse copy of the array. // TODO: Display the contents of the new array. return 0; } // ******************************************************** // The reverseArray function accepts an int array and an * // int indicating the array's size. The function returns * // a pointer to an array that is a reverse copy of the * // array that was passed as an argument. * // ******************************************************** int *reverseArray(int arr[], int size) { int sourceIndex; // Index into the source array int targetIndex; // Index into the target array // TODO: Make sure the size is positive and // non-zero. // TODO: Allocate an array large enough to hold // a copy of the array that was passed as // an argument. // TODO: Copy arr's elements, in reverse order, to // the new array. // TODO: Return a pointer to the new array. return copy; } // ******************************************************** // The showArray function displays the contents of an int * // array. * // ******************************************************** void showArray(int arr[], int size) { // TODO: Display the array in the output console. }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started