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 aprogram named stats.g that Plwill do the following: 1. Ask the userto enter up to twenty values of weights in kilograms, with zeroas the sentinel value. (These input values can have decimal points in

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 : #include You will also need to keep a separate array of the closest value(s) to the average. The pseudo-code is something like this: // first, find the minimum deviation from the average set minimum deviation to weights[0] - average for = 0 to number of items if (weights[i] - average)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!