I wrote a min/max program differently this time using a string to number conversion just to try something different. Anyway, the sum & min statements appear to work but the max part doesn't work. Where is my problem? How can I fix it? Thanks.
int sum = 0;
for (int i=1; i<=5; i++)
cout<<"Enter value "<<i<<": ";
if (!(istringstream(value) >> num)) num = 0;
if (num < min)
min = num;
if (num > max)
max = num;
sum += num;
Thanks for the reply histrungalot! When I tried the INT_MIN & INT_MAX, both the min & max went bonkers. When I initialized with max=min=num;, both the min & max picked up the last entry.
The string to number conversion doesn't work too well right now compared to just using a straight number in the first place. My other min/max programs work properly unlike this one. I hoping that someone might have a solution to this problem. Thanks again!