View Single Post
Join Date: Nov 2006
Posts: 3
Reputation: mcweezle is an unknown quantity at this point 
Solved Threads: 0
mcweezle's Avatar
mcweezle mcweezle is offline Offline
Newbie Poster

Re: finding the smallest number

 
0
  #6
Nov 13th, 2006
Okay.... i tried this, but now i get a value of whatever the last number entered was. So, if my input is 1, 4, 8, -99... it ignores the -99, which is what I want, but it says the smallest number would be 8. .... what am I missing?

  1.  
  2. case 'b':
  3. case 'B':
  4.  
  5. cout << " Enter a group of numbers. I will tell you the smallest number. \n Enter " << SENTINEL << " to exit." << endl;
  6. counter = 0;
  7.  
  8.  
  9. while (number != SENTINEL)
  10. { // open while 3
  11. counter++;
  12. cin >> number;
  13.  
  14. if (number > SENTINEL && temp2 != SENTINEL)
  15. temp2 = number;
  16.  
  17. }
  18.  
  19. cout << "Your smallest number out of " << counter << " was " << temp2 << "." << endl;
  20. cout << endl;
Reply With Quote