Page 86 - 2502_Pakistan-kifayat_C-7
P. 86

Example:


                              Move 1 step down                              St
                              Repeat 5 times
                              (

                              Fill colour
                              Move 1 right

                              )



              Infinite Loop

              An infinite loop, on the other hand, keeps repeating the instructions forever unless it is manually
              stopped or interrupted by a condition. This type of loop is used when you want a task to continue
              without ending, such as making a sprite keep moving or playing background music throughout a game.
              Infinite loops are helpful for continuous actions that do not have a fixed end. For example, if a robot
              needs to move continuously, an infinite loop can be used to keep moving.
              Example:


                              Move 1 step down                              St

                              Repeat until  reached last
                              column

                              (
                              Fill colour
                              Move 1 right

                              )



                       Factbot

                According to a research, coding activates five brain regions, which are related to working memory, attention,
                and language processing, which may enhance the process of learning.





                   INSTRUCTIONS FOR CORRECT ALGORITHM

              An algorithm is a list of clear and step-by-step instructions to solve a problem or complete a task.
              Algorithms should be accurate, logical, and easy to follow.

              Some of the basic instructions that we can follow while writing an algorithm are as follows:

                  It begins with the keyword “Start”.
                  It is written using simple English-like statements.

                  It is not case-sensitive; it can be written in uppercase, lowercase, or mixed case.



                  84  Premium Edition-VII
   81   82   83   84   85   86   87   88   89   90   91