Place source code files for this assignment in a folder named arrays within your
ID: 3696119 • Letter: P
Question
Place source code files for this assignment in a folder named arrays within your Cloud9 workspace. The files should be named as exl.cpp for exercise 1, ex2.cpp for exercise 2, and so on. int mymaximum(int a[], int numberOfElements); Provide an implementation of the mymaximum function whose declaration is shown above. The first argument of the function is an array of int and the second argument is the number of ints that are in the array. The function returns the largest int that is in the array. Write test code that thoroughly tests the function. The test code should use assertionsExplanation / Answer
Answer:
int mymaximum(int a[], int numberOfElements)
{
int maximum_value = 0;
for(int i = 0; i < numberOfElements; i++)
{
if(a[i] > maximum_value)
{
maximum_value = a[i];
}
}
return maximum_value;
}
int main() {
int values[] = {98,48,60,73,21,65,34,98,76,12,85,43,87};
cout << "The maximum value in array is: " << mymaximum(values, sizeof(values) / sizeof(values[0])) << endl;
return 0;
}