Page 88 - Viva ICSE Computer Studies 8 : E-book
P. 88

Syntax:
                     Do
                                                                                                     Code block
                     {
                                                                                           If test condition
                     ………………….                                                              is true

                     Statements                                                                         Test
                     }                                                                                condition
                     While(test condition);                                                                If test condition

                                                                                                           is false

                    Do While loop is also called exit controlled loop. This is because it checks the condition after
                    executing the block of statements.

                    Example:  Write a program to print fi rst 10 natural numbers






























                                                           Think and Discuss


                                           How many times will the following body of loop execute?
                                           For(int n=1;n<=10;n++)
                                           {
                                           System.out.println(n);
                                           }



                            Computer Etiquette


                      While writing a loop, conditions should be thoroughly checked for proper execution and accurate results.


                       Tech Terms
                      Loop:  Execution of statements again and again




                     76
   83   84   85   86   87   88   89   90   91   92   93