Paul Clapham wrote:Okay. So I could enter -2 and -4 and -17 and your code would go on to find the second largest of those three numbers? What would it output?
Campbell Ritchie wrote:That sort of code suggests you are only dealing with natural numbers. . . .
pshivvy pat wrote:. . . -1 is there as a value which we were instructed to stop at. . . .
Paul Clapham wrote:
Campbell Ritchie wrote:The problem about −1 comes from misunderstanding the loop in line 7. All you have to do is enter a non‑integer and the loop terminates. No need for −1 or break; or anything like that.
Right. But what if I wanted to use -1 as one of the numbers I'm inputting? Or some other negative numbers? The posted code won't handle those properly.