Page 55 - Touchcode_C3_Flipbook
P. 55

4.3                      UNDERSTANDING PROGRAMS










                 Let us understand the difference between algorithm and program.


                             An algorithm is a list of            A program is an algorithm that
                             steps you can follow to             has been ‘coded’ into something

                                     do a task.                    that can be run by a machine.



                 Now that we have learnt about the difference between algorithm and program, let’s

                 try to write a program to colour the squares diagonally.


                  3                                  3                                 3



                  2                                  2                                 2



                  1                                  1                                 1


                        A        B         C               A        B        C               A         B        C


                 Step  1    Start and              Step  2    Move one square            Step  3   Colour B2.
                            colour A1.                        right and move one
                                                              square up.






                                  3                                    3


                                  2                                    2



                                  1                                    1


                                        A        B        C                  A        B         C


                             Step  4    Move one square                 Step  5  Colour C3.
                                         right and move one
                                         square up.

                                                                         Level 4: Algorithmic Intelligence       53
   50   51   52   53   54   55   56   57   58   59   60