I'm working on a homework assignment and probably know too much about this stuff, so I'm just looking for a job. Here is the basic code:
for(x = 100; x > 0; x = x + x) { sum = sum + x;
There are two versions: one where x is a float and the other is int . The question is whether these are endless loops.
I think that when x is int , it will eventually overflow, making it less than zero, and the loop will stop. When x is a float , x will reach infinity, and the loop will be infinite.
I close?
source share