Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions