Get someone to read these numbers to you, and you try to remember what the highest and lowest numbers you hear.

31
47
85
64
95
48
45
86
26
61
47
76
98
80
62
19
4
12
10
78

Use a vector.

"Without using an array" generally means "without storing all of the numbers", which means vector is out too. But even if you could store all of the numbers, doing so would be stupid because it's trivial to write a linear algorithm without wasting memory like that.

True enough. I assumed wrongly that it had more to do with setting a specific size of an array, with regards to allocation and things like that. Also, since the program isn't really asking for the set of data but only the largest and smallest out of those entered, it doesn't make sense.

Easy enough, assuming some things.

int maxVal  = INT_MIN;
int minVal = INT_MAX;
int input = -1;
const int END  = -1;
while( cin >> input ){
  if( input == END) break;
  else{
    minVal = std::min(minVal,input);
    maxVal = std::max(maxVal,input);
  }
}
This article has been dead for over six months. Start a new discussion instead.