Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that implements the following functions: 1)Write a function named getProduct with no formal parameters that requests a collections of positive and negative

Write a program that implements the following functions:

1)Write a function named getProduct with no formal parameters that requests a collections of positive and negative integers from the user and multiplies only the positive integers. Loop exit should occur when three consecutive negative values are read. The product should be returned from the function.

2)Write a function named getStats that receives a single integer named n. The function requests n doubles from the user and then outputs the smallest number, largest number, and the average of all the numbers entered. The function does not return anything.

2)Write a main function that tests both functions.

Example Output:

Function 1:

Testing getProduct

Enter positive #: 2

Enter positive #: 4

Enter positive #: 8

Enter positive #: -1

Enter positive #: 2

Enter positive #: -1

Enter positive #: -2

Enter positive #: -3

Product of positive integers is 128

Function 2 : Enter n: 4

Testing getStats

#1: 2

#2: 3

#3: 4

#4: 1

Smallest: 1

Largest: 4

Average: 2.5

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

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

What is the purpose of a code of conduct?

Answered: 1 week ago

Question

13-1 How does building new systems produce organizational change?

Answered: 1 week ago