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
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
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