[Solved] C code to repeatedly ask the user for a number

Click And Check all our Assignments
Click Here and Upload you Assignment for Free!


100/100 Trustscore on scamadviser.com

10 USD $

Category: Tag:

5/5 – (2 votes)

Write C code to repeatedly ask the user for a number, then once the user enters 0, the code displays the min, max and average of all values entered.

To get proper credit, name the variables as listed below and follow the directions carefully. Do not use any break or similar type of statements.

To implement the above code, you will need to count the entries – name the counter variable num_count.

You will also need to use a variable, name it min_in so each time the user gives input, and the input is not 0, then compare min_in with the input, if the min_in is input, then assign min_in to the input.

Similarly name another variable max_in, and compare it to the input, but assign max_in to the input only if max_in is < input.

To calculate the average, accumulate each input into a variable, total. Then after the loop the average is the total divided by the number of entries.

Once the loop is over, display the calculated values (min, max and the average) with a proper wording in three lines. The input is not restricted to integer value so declare the variables above with a proper type. Show the output using two decimal places, and align the three output values as in this sample output:

The minimum entry was: 2.30The maximum entry was: 62.51The average of all entries was: 52.81


There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] C code to repeatedly ask the user for a number
10 USD $