Question: In this exercise you're going to write a computeStats function that given an integer array of size N, returns a structure containing the min, max

In this exercise you're going to write a computeStats function that given an integer array of size N, returns a structure containing the min, max and average of the array. The struct allows the function to return 3 values without having to use parameters and pass-by-reference. Here's the struct definition your function will be returning:

struct Stats { int Min; int Max; double Avg; }; 

Here's an example of how the function would be called from main():

int main() { int N; int* A; . . // allocate array and fill with data: . Stats stats; stats = computeStats(A, N); cout << stats.Min << ", " << stats.Max << ", " << stats.Avg << endl; 

The main() program and struct have been defined for you. Your assignment is to write the computeStats function in the file "util.cpp". [ Select "util.cpp" from the drop-down list above the coding window. If the window is blank, click "Load default template" to obtain the starter code. ]

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!