I am trying to build a program using a sentinel loop and I know I am missing a piece of the puzzle however I am clear on how to make it work. I want the smallest number when I terminate the program by using -99 but I am getting -99 as the smallest number. Any assistance I would greatly appreciate.
You aren't storing the smallest number in another variable. Try this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
...
int n;
int SENTINEL = -99;
int smallest = 255;
cout << "Start here enter > ";
cin >> n;
while (n != SENTINEL)
{
if (n < smallest) //if 'n' is smaller than the smallest number
smallest = n; //make the smallest number equal to 'n'
cout << "Please enter the next number > ";
cin >> n;
}
...