Page 113 - Learn to Program - Basic-256
P. 113

Chapter 8: Looping and Counting - Do it Again and Again.                         Page 97


                   … runs until you stop it
            Sample Output 43: Loop Forever






                              while condition
                                  statement(s)
                              end while

                              Do the statements in the block over and over again while the
                              condition is true.


                              The statements will be executed zero or more times.




                   Program 44 uses a while loop to count from 1 to 10 like Program 38 did with
                   a for statement.



                1       # whilefor.kbs
                2
                3       t = 1
                4       while t <= 10
                5          print t
                6          t = t + 1
                7       end while

            Program 44: While Count to 10




                   1
                   2
                   3
                   4
                   5
                   6
                   7



                                                           © 2019 James M. Reneau (CC BY-NC-SA 3.0 US)
   108   109   110   111   112   113   114   115   116   117   118