#include <iostream>
using namespace std;
int main()
{
const int MAX = 10; // max loops
int count = 0; // count for the while loop
int smallest; // output
int largest = 0; // output
int input; // stores each number read
cout << "Enter 10 integers => ";
while(count < MAX)
{
cin >> input;
if(input >= largest)
{
largest = input;
++count;
}
if(input <= smallest)
{
smallest = input;
++count;
}
if(input < largest and input > smallest)
{
++count;
}
}
cout << "The largest is: " << largest << endl;
cout << "The smallest is: " << smallest << endl;
return 0;
}
My program does not increment count whenever there is a negative number.
Negative integer test case works with 11 integers but not with 10