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