View Single Post
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: finding the smallest number

 
0
  #7
Nov 13th, 2006
You still haven't initalized temp2.

By the way, here's what I think it should look like:
  1. temp2 = -99;
  2.  
  3.  
  4. while (number != SENTINEL)
  5. { // open while 3
  6. counter++;
  7. cin >> number;
  8.  
  9. if (number == -99) {
  10. break;
  11. }
  12. if (number < temp2 || temp2 == -99)
  13. temp2 = number;
  14. }
Probably not the best way of doing it, but it works.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote