   i
  i[Edited by - aeleneski on April 24, 2006 11:14:57 PM]
  What method are you using to get input? And what programming language? ;  After you use operator >>() on cin, check the fail bit (cin.fail()). If the fail bit is set then the extraction operation couldn''t be performed, and probably because the input wasn''t actually an integer.I''m guessing what''s happening in your code is that when you perform extraction on the stream, it fails the operation and sets the variable you used to a negative number. When you enter your loop it continues to fail and thus you go into an infinite loop. ;quote:Original post by aeleneski  but if at any time I put in something other than a negative or positive number the program would freeze.That would be the infinite loop he talked about.Read your input into a string and use a stringstream to extract the number. If it fails then you can admonish the user to enter a number without hanging. 