This is a question on one of my homework assignments and I have it narrowed down between these two but I'm not sure which one it is. Anyone know it?

To avoid an infinite loop make sure the loop body: alters the exit condition or contains at least one output statement?

Recommended Answers

All 2 Replies

Which seems to make more sense? Try them side by side.

To avoid an infinite loop make sure the loop body alters the exit condition.
To avoid an infinite loop make sure the loop body contains at least one output statement.

Would altering the loop exit condition affect looping? Or would an output statement affect loop operation?

To avoid an infinite loop, you should make sure the condition or test value is not skipped over. That's as far as I know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.