set number to 3
while (number is 3 or more)
write out number
increase number by 1
write "finished"
i would if some one can help me how many loop body will be executed with the
way i look at it in's an infinitive loop. the number starts at three andit
will always be 3 or more.
vicki

Signature
v davies
David Kerber - 08 Dec 2005 16:35 GMT
> set number to 3
> while (number is 3 or more)
[quoted text clipped - 5 lines]
> way i look at it in's an infinitive loop. the number starts at three andit
> will always be 3 or more.
In mathematics, yes, but in the computer world that will only be true
until it rolls over past the max value of the variable type holding the
loop index.

Signature
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Hiran Chaudhuri - 08 Dec 2005 21:22 GMT
> set number to 3
> while (number is 3 or more)
[quoted text clipped - 7 lines]
> will always be 3 or more.
> vicki
That one heavily depends on the interpreter for this language.
There will probably be a datatype that can take an arbitrary number of
digits. And depending on the interpreter you might see an overflow if the
number gets 'max_number+1'. Then it might either be negative and the loop
terminates, or you might see an exception or error message. Depending on the
number of digits your data type 'number' has, you can wait pretty long......
Hiran
Roedy Green - 08 Dec 2005 23:30 GMT
>set number to 3
>while (number is 3 or more)
[quoted text clipped - 6 lines]
>will always be 3 or more.
>vicki
This is trick question. Write the loop and run it, and to your suprise
the loop will eventually stop, because of he way integers wrap around
to negative after they get too big. Try adding 1 to Integer.MAX_VALUE
to see what I mean.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.