Page 53 - Touchcode_C3_Flipbook
P. 53

4.2                                                                 ALGORITHM










                 An  algorithm is a set of steps in  a sequential manner to solve a problem or to
                 complete a task. The problem can be logical or mathematical.



                 Let’s write an algorithm to find sum of two numbers.

                 Step  1   Start


                 Step  2  Read two numbers (Input)


                 Step  3  Add two numbers

                 Step  4  Print the sum (Output)


                 Step  5  Finish


                                          Coding fact


                   Algorithms are the building blocks of computer programs. The steps may involve
                   input (asking value from user) and output (giving back results to user).








                        CRACK THE CODE                                                             ADVENTURE

                 A.  Complete the steps to write an algorithm to find your age.                               Time Taken

                      Take help from the hint box.                                                      Min.



                      Step  1         _________________


                      Step  2         Ask birth year

                      Step  3         Age = _________________ — Birth year           HINTS       Current year,
                                                                                                 Start, Result
                      Step  4         Display _________________

                      Step  5         Stop



                                                                         Level 4: Algorithmic Intelligence       51
   48   49   50   51   52   53   54   55   56   57   58