Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

=+4 Are national cultures converging or diverging?

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago