View Single Post
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: finding the smallest number

 
0
  #4
Nov 12th, 2006
Your error lies in here, you should make sure the number you are reading IS NOT the sentinel AND smaller than the current smallest number before assigning it to temp2 (use an if then statement). Second of all is why are you performing cin >> number two times in a row?

  1. while (number != SENTINEL)
  2. { // open while 3
  3. counter++;
  4. cin >> number;
  5. {
  6. cin >> number;
  7. if (number < temp2)
  8. temp2 = number;
  9. }
  10. }
Reply With Quote