Write a function named “highestScore” that takes an array of floating point scores and its size as parameters and return the highest of these scores.
The function prototype:
float highestScore(float scores[], int size);
#include <iostream> using namespace std; float highestScore(float scores[], int size); int main() { float scores[] = {4.5, 9.2, 1.4, 5.7, 6.2}; cout << highestScore(scores, 5) << endl; return 0; } float highestScore(float scores[], int size) { float max = scores[0]; for (int i = 0; i < size; ++i) { if (scores[i] > max) max = scores[i]; } return max; }
Get Answers For Free
Most questions answered within 1 hours.