Page 73 - ModularV1.1 _c7_flipbook
P. 73

Program 5: To print all odd numbers from 1 to 24.
















                 Program 6: To print the number from 1 to 10 in reverse order.















                 Program 7: To find the sum of numbers from 1 to 100.

















                     WHILE…END...WHILE STATEMENT

                 The WHILE…END...WHILE loop is another looping statement. This loop is used when we do
                 not know the loop count. The FOR...NEXT loop will run for a fixed number of times, but the
                 WHILE  loop will run until the given
                 condition remains true.  This is similar
                 to telling someone to keep doing a
                                                                                    True     Execute statements
                 particular task while the condition is true,        Condition?              in the body of the

                 and  stop  when  the  condition becomes                                        WHILE loop.
                 false. WHILE...END...WHILE loop is known
                                                                    False
                 as a Condition Control loop. The basic
                                                                    Move to the
                 syntax of the WHILE...END...WHILE loop is
                                                                 statement after the
                 as follows:
                                                                END WHILE keyword
                 WHILE (condition is true)
                      Statements to Repeat
                 END WHILE


                                                                    Conditional and Looping Statements in BASIC-256  71
   68   69   70   71   72   73   74   75   76   77   78