O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The while Loop

The first of the uncounted loops that you’ll read about is the while loop. In this context, an uncounted loop is simply one where you might not know in advance how many iterations you need to perform, but you can test for a condition that will enable you to determine that the loop is complete, in other words, that it has repeated enough times to perform a given task.

A while loop consists of a condition to be evaluated and a set of statements, contained in braces, that are executed until the condition evaluates to false (in other words, fails). So while the condition is true, you continue to execute the associated code block.

The condition that you test can be anything that could be used in an if statement. This might include variables, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required