do-while loop

View


Syntax-

                                                 Initialization of loop variable
                                                do                                           
                                                {
                                                            Statements (s);
                                                            Increment/decrement of loop variable;
                                                 } while ( condition using loop variable );

 

A condition using loop variable is specified with while-statement. If the condition is FALSE then the control will come out of the while block, if the condition is TRUE then the statements inside while block will be executed again and again until the condition becomes FALSE.

Difference between while-loop and do-while loop

Example-


Flowchart-



Last modified: Tuesday, 21 September 2021, 9:45 AM