For my assignment I am to write a program that reads a series of integers from the keyboard. I am also required to use a sentinel number (a number that causes the loops to halt and display the results). Once the user has entered a series of integers ranging from 1 to 100, the user will then enter a sentinel number to stop the loops. The resulting output should show the average of the integers as well as the maximum and minimum integers.
I know how to code a loop with a sentinel number that halts it, but I am unsure of how to make the program display the maximum and minimum integers in the user given numbers. We have not learned arrays yet so I am now allowed to use them. In my notes, I have written down that the teacher said to use climits int_min and int_max I think. I am just unsure how to code these as my book does now show this.
> the teacher said to use climits int_min and int_max
int minimum = std::INT_MIN ; // smallest possible int
int maximum = std::INT_MAX ; // largest possible int
double sum = 0 ; // holds sum of all integers
the loop would look like this in pseudocode:
1. read a number entered by the user
2. if number == sentinel break
3. add number to sum
4. if number < minimum set minimum <- number
5. if number > maximum set maximum <- number
6. go to 1.