None of the cool kids use the do-while loop, but for completeness, here it is. The do-while loop doesn’t check the expression until it has executed the block. Thus, it ensures that the block is always executed at least once. If you rewrote the original exercise to use a do-while loop, it would look like this:
int main(int argc, const char * argv[]) { int i = 0; do { printf("%d. Aaron is Cooln", i); i++; } while (i < 13); return 0; }
Notice the trailing semicolon. That’s because unlike the other loops, a do-while loop is actually one long statement:
do { something } while ( something else stays true );
Here’s a flow-chart of this do-while loop: