Wednesday 1 December 2010

For which values of the integer _value will the following code becomes an infinite loop? int number=1; while (true) { cout << number; if (number == 3) break; number += integer_value; }

► any number other than 1 or 2
only 0 
► only 1
► only 2
Rational:
number += integer_value
above line decide the fate of loop so any thing other then zero leads to value of 3 which
will quite the loop. Only zero is the value which keeps the loop infinite.

No comments:

Post a Comment