Solved:

Checkmark

Answered by AI, Verified by Human Experts

4.15 LAB: Varied amount of input data

4.15 LAB: Varied amount of input dataStatistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the max and average. A negative integer ends the input and is not included in the statistics. Assume the input contains at least one non-negative integer.

Output the average with two digits after the decimal point followed by a newline, which can be achieved as follows:
printf("%0.2lf\n", average);

Ex: When the input is:

15 20 0 3 -1
the output is:

20 9.50
In C programming language NOT C++

Final answer:The C program should calculate the max and average of an undetermined number of non-negative integers, ending input with any negative integer, and then output these values.Explanation:The task is to write a C program that calculates statistical data such as maximum value (max) and average from a series of non-negative integers and outputs these figures, terminating the input when a negative integer is encountered. The program must ignore the negative integer and must provide the average to two decimal places using the specified printf format.Example Program Flow:Initialize variables to store sum, count, max, and a temporary input.Use a loop to read numbers until a negative integer is inputted.Update sum, count, and max with each inputted non-negative integer.Calculate the average by dividing the sum by the count.Output the max and average as specified....

Unlock full access for 72 hours, watch your grades skyrocket.
For just $0.99 cents, get access to the powerful quizwhiz chrome extension that automatically solves your homework using AI. Subscription renews at $5.99/week.