Question: C programming code and A flowchart please. Program Description Write a program named stats.g that Plwill do the following: 1. Ask the user to enter




C programming code and A flowchart please. Program Description Write a program named stats.g that Plwill do the following: 1. Ask the user to enter up to twenty values of weights in kilograms, with zero as the sentinel value. (These input values can have decimal points in them.) These numbers will go into an array. If your program receives a negative value, it will give an error message, it will not put the value into the array, but will continue asking for values. 2. Print the number of weights that the user entered. 3. Print the average weight. 4. Print the number of values closest to the average and print the value(s). Sample Output Here are two samples of the result of running the program: Enter a weight in kg, or 0 to quit: 13.5 Enter a weight in kg, or 0 to quit: -2.4 Ignoring negative value. Enter a weight in kg, or 0 to quit: 14.7 Enter a weight in kg, or 0 to quit: 22.2 Enter a weight in kg, or 0 to quit: 18 Enter a weight in kg, or 0 to quit: 0 Number of entries: 4 Average weight: 17.100 kg Number of items closest to average: 1 The item(s) - weight in kg: 18.000 Enter a weight in kg, or 0 to quit: 7.5 Enter a weight in kg, or 0 to quit: 9 Enter a weight in kg, or 0 to quit: 8.5 Enter a weight in kg, or 0 to quit: 7.0 Enter a weight in kg, or 0 to quit: 0 Number of entries: 4 Average weight: 8.000 kg Number of items closest to average: 2 The item(s) - weight in kg: 7.500 8.500 Hints For step 3, you can calculate the sum of the of the items as you read them in; you don't need to wait until all the numbers have been entered. You do have to wait until all the items have been entered to calculate the average. For step 4, you will need to use the absolute value for floating point (or double) values: fabs(). To use this function, you must put this line into your code after the #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
