Page 67 - Touchcode_C5_Flipbook
P. 67

4.3                                             PROGRAMS : LOOPS










                 In programming at times, we need to repeat a block of code a certain number of
                 times. To do so, we use loops. Loops are used to repeat a block of code based on a

                 condition.




                        CRACK THE CODE                                                             ADVENTURE



                 A.   Write the program to take Ananya to her home.                                           Time Taken
                                                                                                        Min.

                           START












                                                                                                           END

                               Program without loop                           Program with loop


                                  Move one step
                                  Turn right

                                  Move one step

                                  Turn left

                                  Move one step
                                  Turn right

                                  Move one step

                                  Turn left

                                  Move one step
                                  Turn right

                                  Move one step

                                  Turn left


                                                                         Level 4: Algorithmic Intelligence       65
   62   63   64   65   66   67   68   69   70   71   72