Question: 2. Write the definition of a function that calculates the sum and average of the numbers in an interval. a. The preconditions are that the

2. Write the definition of a function that calculates the sum and average of the numbers in an interval. a. The preconditions are that the input to the function is two integer values and that the first number is less than the second number. i. Make sure to provide code inside the function that ensures the preconditions are met. For example, if the end points of the interval are passed in the wrong order, your code would need to adjust them. b. The postcondition is that the sum of the numbers in the interval and the average of the numbers in the interval is returned. Since a function can only return a single result, your function would be declared as a void function and the results would be returned through reference parameters that are declared in the caller. i. Notice that the postcondition does not say anything about displaying these values. The caller of the function decides what to do with the values after the function calculates them. c. In your program, provide the prototype for this function and comments documenting the preconditions and postconditions (either before or after the prototype). d. Place the function definition after the main function.

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!