The C language contains two main looping constructs:
A while loop is constructed as follows:
while ( some condtion is true ) {
/* do something repeatedly
*/
}
The brackets after the while statement ( note these things: {} are called
braces) contain some conditional statement,
e.g
while (i < 100) {
:
:
i++;
}
C treats conditional tests in a slightly unusual way. Essentially
something is true in C if it is not zero. So the following
will set up an infinitely repeating loop.
while ( 1 ) {
:
:
}
Conditions are most commonly tested in C using the if statement as follows:
if ( some condition ) {
/* do something */
}