The do statement provides an iterative structure to condidionally repeat execution of a section of code sy least once.
The do statement is used as an iteration, or looping, structure. Loop control occurs after the body of the loop. The body of the loop will be executed one or more times.
#include <stdio.h>
int main () {
unsigned i;
i = 0;
do {
if (i % 2 == 1) {
printf ("%u is an odd number\n", i);
}
++i;
} while (i < 10);
return 0;
}
| Statement | <statement> |
| Compound Statement | <compound-statement> |
| for Statement | <for-statement> |
| while Statement | <while-statement> |
|
C Now
| C do Statement |
| C++ Now | C++ do Statement |
| Java Now | Java do Statement |
| Pascal Now | Pascal Repeat Statement |
| PHP Now | PHP do Statement |