YouTip LogoYouTip

C Do While Loop

# C do...while Loop [![Image 4: C Loops](#) C Loops](#) Unlike **for** and **while** loops, which test the loop condition at the top of the loop, the **do...while** loop in C checks its condition at the bottom of the loop. The **do...while** loop is similar to the while loop, but the do...while loop guarantees that the loop is executed at least once. ## Syntax The syntax of the **do...while** loop in C: do{ statement(s);}while( condition ); Notice that the conditional expression appears at the end of the loop, so the statement(s) in the loop will execute once before the condition is tested. If the condition is true, the control flow jumps back up to do, and the statement(s) in the loop execute again. This process repeats until the given condition becomes false. ## Flow Diagram ![Image 5: do...while loop in C](#) ## Example ## Example #include int main () { /* Local variable definition */ int a =10; /* do loop execution - executes at least once before condition is tested */ do { printf("Value of a: %dn", a); a = a +1; }while( a See more: (#) [Is that really you~](javascript:;)Is that really you~ 177***9850@qq.com 3 years ago (2023-03-02) ### Click to Share Note
← C Nested LoopsPython Command Line Arguments β†’