Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    C do while loop

    C do-while loop is very similar to the while loop, but it always executes the code block at least once and as long as the condition remains true. It is an exit-controlled loop. This tutorial guides you on how to use "do while loop" in the C program.

    The basic format of the do-while loop statement is:

    Syntax:

    do
    {
       statement(s);
    
    } while( condition );

    Figure - Flowchart of the do-while loop:

    Example of a C Program to Demonstrate do-while loop

    Example:

    #include<stdio.h>
     
    int main ()
    {
       /* local variable Initialization */
       int n = 1,times=5;
    
       /* do loops execution */
       do
       {
           printf("C do while loops: %d\n", n);
           n = n + 1;
       } while( n <= times );
     
       return 0;
    }

    Program Output:


    C do while loops - Video Tutorial

    Please watch this tutorial to understand "C do while loops" in more depth.



    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.