January 2015
Intermediate to advanced
96 pages
1h 20m
English
CHAPTER 9
![]()
Loops
There are three looping structures in C, all of which are used to execute a specific code block multiple times. Just as with the conditional if statement, the curly brackets for the loops can be left out if there is only one statement in the code block.
While Loop
The while loop runs through the code block only if its condition is true, and will continue looping for as long as the condition remains true. Bear in mind that the condition is only checked at the start of each iteration.
int i = 0;while (i < 10) { printf("%d", i++); /* 0-9 */}
Do-While Loop
The do-while loop works in the same way as the while loop, except that it checks ...
Read now
Unlock full access