Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 103 - 2505_CoreGPT(Podar)_Flipbook_C7
P. 103

    Looping Control Statements
                              8                                  in BASIC-256

                         Goal Glimpse

                             Looping Statements                              Infinite Loop
                             Pause Statement                                 Nesting of Loops

                     This chapter covers FOR...NEXT and WHILE...END...WHILE loops in BASIC-256, helping you repeat
                     tasks efficiently. You’ll also learn how to use the PAUSE statement and nested loops for more
                     complex tasks.

                           LOOPING STATEMENTS

                     To print the numbers from 10 to 1 you can create a program in two ways. You can either give
                     separate instructions to print each output or give a single set of instructions to print the output.
                     This set of instructions will repeat for a fixed number of times or until a condition is satisfied. This
                     is called looping. In BASIC-256, the statements used for repetition of instructions in a program

                     are called iterative statements or looping statements. All the statements mentioned within
                     a loop is called the body of the loop. Looping statements are very useful and necessary for
                     developing an application. BASIC-256 provides FOR...NEXT and WHILE...END WHILE as looping

                     statements. Let's learn about them.
                     Key Components of a Looping Statement

                     The structure of a looping statement consists of the following four essential parts:

                     1.  Initialization: This step sets up the counter variable, which controls how many times the
                         loop will run.

                     2.  Test Condition: This checks whether the loop should continue or stop, by evaluating a
                         specific condition. The loop ends once this condition is no longer met.

                     3.  Body of the Loop: This contains the statements that are executed repeatedly as long as the
                         test condition holds true.

                                                                         Looping Control Statements in BASIC-256        101

| 98 99 100 101 102 103 104 105 106 107 108 |