Page 57 - 6437
P. 57

do...while loop            It is more like a while statement, except that it tests the
                                                            condition at the end of the loop body.



                                         nested loops               You can use one or more loops inside any other while,
                                                            for, or do..while loop.


                          while Loop
                          A while loop in C programming repeatedly executes a target statement as long as a given
                   condition is true.

                          Syntax
                          The syntax of a while loop in C programming language is:

                 while(condition)

                 {
                    statement(s);
                 }


                          Here, statement(s) may be a single statement or  a  block  of  statements.  The condition
                   may be any expression, and true is any nonzero value. The loop iterates while the condition is
                   true.
                          When the condition  becomes  false, the program control passes to the line  immediately
                   following the loop.

                          Flow Diagram

































                                                                                                      59
   52   53   54   55   56   57   58   59   60   61   62