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