Page 61 - Touchcode_C4_Flipbook
P. 61

4.3                                              PROGRAMS : LOOPS










                 A loop is repeating a particular task or instruction for fixed numbers of times.

                 Robby has to paint these blank boxes to make a letter ‘U’



















                 The program will be


                   Move 1 down                                          Repeat 4 times

                   Move 1 down                                          (Move 1 down)
                   Move 1 down

                   Move 1 down                                          Repeat 3 times

                   Move 1 right                                         (Move 1 right )

                   Move 1 right
                   Move 1 right                                         Repeat 4 times

                   Move 1 up                                            (Move 1 up)

                   Move 1 up

                   Move 1 up
                   Move 1 up


                       Program without a loop                                 Program with a loop



                                          Coding fact

                   Algorithm or program with repeat statements is shorter as compared to the

                   algorithm or program without repeat statements.



                                                                         Level 4: Algorithmic Intelligence       59
   56   57   58   59   60   61   62   63   64   65   66