Help with a min/max problem

I am having problems getting correct output for my code that is supposed to read an unspecified number of integers until EOF and then output the maximum and minimum values entered. I must be overlooking something simple as I have been working on this for longer than I care to disclose. Any help would be greatly appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 using namespace std;

int main()
{
int number,maximum,minimum;
int count = 0;
	
	cout << "Enter a number, EOF to quit: " << endl; 
	cin	>> number; 
	number=maximum=minimum;

while( cin >> number )
{

	if ( number > maximum )
		maximum=number;
	
	else if(number < minimum)
		minimum=number;
	
	count++;
	
}
if ( count == 0 )
	{
		cout << "No data was entered, there are no minimum or maximum values." << endl; // If no data is entered (only the EOF) then this message is displayed
		return 1;
	}	
else if ( count != 0 )

cout << "The maximum number is: " << maximum << endl
     << "The minimum number is: " << minimum;  

	 return 0;
	
}	
1
2
// number=maximum=minimum; // line 10
maximum = minimum = number ;
Once again, you are my savior.
Last edited on
Topic archived. No new replies allowed.