Question
code in c program Min, Max, Mean: Advanced Program Write a program that finds the smallest (min), largest (max), and average (mean) of N values
code in c program
Min, Max, Mean: Advanced Program
Write a program that finds the smallest (min), largest (max), and average (mean) of N values entered by the user. Your program should begin by prompting the user for N, the number of values to be entered. Then the program should accept that number of values, determining the min, max, and mean. Then it should display those values.
This is an extension of a previous lab. First, get it working for N values. Then, extend it to include error-checking, in case the user makes a mistake when entering values.
When scanning for a value for N, the program should use error checking to protect against erroneous inputs from the user and only accept positive integer values. The other values entered can be any value, but error checking should still be employed to ensure that the user entered a value. If there is ever an incorrect input the user should be re-prompted for the value and told of the error.
Steps for the program:
- Prompt the user for N
- Scan the value of N
- Prompt and Scan for N Values
- Simultaneously search for Max and Min values
- Add all values to generate a sum
- Calculate the average by dividing the sum by N, MEAN=sum/N
- Display min, max, and mean values
An example run of the program is given below where the user enters five values (ie N=5):
MIN, MAX, and MEAN CALCULATOR How many values are to be entered?: -4 INPUT ERROR! How many values are to be entered?: 4 Value 1: 2 Value 2: as INPUT ERROR! Value 2: 17 Value 3: 3 Value 4: 5 The minimum value is 2, the maximum value is 17, and the average value is 6.75.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started