Page 332 - Web Applications (803) Class 11
P. 332

Flow Diagram

                                              Ini aliza on/Star ng
                                                  statement


                                                         Next itera on of the loop





                                                                             Execute
                                                     Test        True    statement(s) inside
                                                  Condi on                  body of loop




                                                       False



                                                Exit from loop

              Example:
                 <HTML>
                 <BODY text="blue">
                 <H2> Using while loop in JavaScript</H2>
                 <SCRIPT>
                 var i = 1;
                 while (i <=5) {
                   document.write("<br><br> The square of "+i+" is "+(i*i));
                   i++;
                 }
                 </SCRIPT>
                 </BODY>
                 </HTML>
              Output:






















                                   Do You Know?


                                   Any  non-zero  value  in  the  while  loop  indicates  always  a  true  condition,
                                   whereas zero indicates always-false condition.



                330     Touchpad Web Applications-XI
   327   328   329   330   331   332   333   334   335   336   337