Question: Implement the function int getMax(const int values[], int size) . It should return the largest int in the array. Hint: Use the chop from the

Implement the function int getMax(const int values[], int size). It should return the largest int in the array. Hint: Use the "chop from the back end by adjusting size" approach. If the size is 1, the max is obvious. Otherwise, you need to compare the "last" element to the max of all the ones that come before it and return the largest of those two. Note that the function is declared above main but you will implement it at the bottom of the code (after loops have been disabled).

#include #include using namespace std;

int getMax(const int values[], int size);

int main() { int nums[] = {5, 12, 9, 7}; int nums2[] = {2, 3, 4}; int nums3[] = {8, 5, 3};

cout << getMax(nums, 4) << endl; cout << getMax(nums2, 3) << endl; cout << getMax(nums3, 3) << endl;

return 0; }

//Disable iterative looping structures... #define for "OhNoYouDont" #define while "GetThatOutOfMyKitchen" #define goto "AwwwHeckNo"

//Do not modify anything on or above the line below this //YOUR_CODE_BELOW

//YOUR_CODE - Implement Function Here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!