IT Log

Record various IT issues and difficulties.

Is do in C equivalent to an infinite loop


In C programming, the do keyword does not represent an infinite loop by itself. It is part of the dowhile loop construct. Unlike the while loop, which checks its condition before executing the loop body, the dowhile loop executes the body at least once and then checks the condition to decide whether to repeat.

A dowhile loop can become infinite if the condition inside it is designed never to fail (e.g., 1 == 1). However, by default, it is not an infinite loop. It depends on the condition provided in the loop structure.


, , , ,