Question
Modify the program to also display the lowest number in the array. Use a value-returning function named getLowest. Test the program appropriately. #include using namespace
Modify the program to also display the lowest number in the array. Use a value-returning function named getLowest. Test the program appropriately.
#include
using namespace std;
// function prototype
int getHighest(int numArray[ ], int numElements);
int main( )
{
int numbers[4] = {13, 2, 40, 25};
cout << "The highest number in the array is "
<< getHighest(numbers, 4) << "." << end1;
return 0;
} // end of main function
//*****function definitions*****
int getHighest(int numArray[ ], int numElements)
{
// assign first element's value to the high variable
int high = numArray[0];
// begin search with second element
for (int sub = 1; sub < numElements; sub += 1)
if (numArray[sub] > high)
high = numArray[sub];
// end if
// end for
return high;
} end of getHighest function
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