General mathematic calculation and number comparison

Write a complete C++ program that prompts the user to enter a series of integers terminated by a 0. The program should then print:

• The number of integers entered (not including the 0)
• The average of the integers (with 1 decimal point of precision)
• The maximum integer
• The minimum integer

Example Output:
Enter a series of integers terminated by a 0:
85 95 75 67 0

Output:
You have entered 4 integers.
The average is 80.5
The maximum is 95
The minimum is 67

The sample out is provided.
Previously i use array to store value and the program is supposed to be stopped by typing 0. Then the total value is calculated except addtional of 0 and the average is divided by 4 only as the source code shown above. HOw do i do to make the total calculation not include 0 ?

1
2
if ( input == 0 )
break; // break the loop before it stores the 0 in array 


Last edited on
Topic archived. No new replies allowed.