4.15 LAB: Varied amount of input data
Statistics 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++

Answers

Answer 1

The program that takes any number of non-negative integers as input, and outputs the max and average is in explanation part.

What is programming?

Making a set of instructions that instruct a computer how to carry out a task is the process of programming. Computer programming languages like JavaScript, Python, and C++ can all be used for programming.

Here is a Python program that takes any number of non-negative integers as input and outputs the max and average:

numbers = []

while True:

   num = int(input())

   if num < 0:

       break

   numbers.append(num)

max_num = max(numbers)

average = sum(numbers) / len(numbers)

print(max_num)

print("%.2f" % average)

Thus, the program uses a while loop to continuously read in input until a negative integer is entered, at which point the loop breaks.

For more details regarding programming, visit:

https://brainly.com/question/11023419

#SPJ1


Related Questions

Other Questions
Find the missing angles measurements pt. 21-5(I point for each question)Please answer all questions and solve step by step and please try to show/explain with the least words as possible and use mostly numbers to for explain there can still be some words tho. suppose geologic evidence found the amount of weathering in the devonian period to be equal to that of other points in the geologic record.which scientist would most likely use this information in support of his or her view? The idea of social integration in which people do similar work and assume that they share similar responsibilities are called: _________ Write a letter to the editor of Punch newspaper telling him that your school is interested in having a column in their Weekly Publication Chester Company earned $12,500 of cash revenue, paid $7,500 for cash expenses, and paid a $200 cash dividend to its owners. Which of the following statements is true?The net cash inflow from operating activities was $5,000.Cash revenue and cash expenses are operating activities. Paying dividends is a financing activity. $12,500 revenue $7,500 expense = $5,000 cash inflow from operating activities. which consideration should be prioritized when choosing a client population during the formulation of a clinical question? Suppose that in an economy the structural unemployment rate is 3.1 percent, the friction unemployment rate is 1.7 percent, and the unemployment rate is 8.1 percent. The natural unemployment rate is_____ percent and the cyclical unemployment rate is _____ percent a. 4.8;3.3b. 6.7; 3.3c.1,4; 3,3d. 4,8; 12,9 the mass and volume of each sample differ from the mass and volume of the other samples. is it possible for each sample to contain 1 mol of each substance? Order them to least to greatest The perimeter of a square must be greater than 138 inches but less than 186 inches. Find the range of possible side lengths that satisfy these conditions. (Hint: The perimeter of a square is given by P=4s, where s represents the length of a side). Express your answer in interval notation. Use decimal form for numerical values. A common point of contention about corporations is a. modem corporations no longer utilize a CID structure. b. if corporations are moral agents, then this relieves individual human beings of any moral responsibility. oc. philosophers and business theorists disagree whether corporations are moral agents. d. corporate punishment is no different from individual punishment. . How was the war going for the South Koreans? Did the US forces initially change this? 1. Calculate the heat (expressed in calories) required to heat 115 g of water from15.4 C to 91.4 C. a salesperson who would like to get as many people as possible to view his open house may use which of the following sales promotions to induce sales traffic? A 2 pound bag of broccoli costs $1.92. What is the price per ounce. match the environment with a way in which a geologist might study that area. volcano volcano drop zone empty. glacier glacier drop zone empty. mineral resource mineral resource drop zone empty. mars mars drop zone empty. ecosystem a is an information system that enables users to retrieve data from the web by using keywords related to their topic of interest. a. data mart b. web server c. search engine Which of the following transport processes would be most likely to move a non-polar gas like CO2 across the plasma membrane? Select an answer: a.diffusionb.secondary active transport.exocytosis Submit Unanswered Write a scenario that will help you understand the following word or topic and show me that you understand their importance. Disciplines - information literacy practices change based on the discipline (or what one isstudying or researching) to determine if information is relevant to the need Complete the following statements by writing the appropriate word or phrase on the correspondingly numbered blank: The two basic tissues of which the skin is composed are dense irregular connective tissue, which makes up the dermis, and .... , which forms the epidermis. The tough water-repellent protein found in the epidermal cells is called . .. . The pigments melanin and .... contribute to skin color. A localized concentration of melanin is referred to as a .... . (choice: 1.stratified squamous epithelium 2.keratin 3.carotene 4.freckle)