Page 93 - Code & Click - 5
P. 93

The revised algorithm and flowchart to make a telephone call to your friend are:


                              Algorithm                                           Flowchart

             Step 1: Pick up the mobile phone.                                         Start

             Step 2: Open the dialler app.                                    Pick up the mobile phone

             Step 3:  Dial the phone number of your                              Open the dialler app
                      friend.                                                  Dial the phone number

                                                                                         Is
             Step 4:  If the dialed number is busy, go to                         the dialled number  Yes
                      Step 5.                                                          busy?
                                                                                          No
                      Else, talk when someone answers.                        Talk when someone answers

             Step 5: End the call.                                                  End the call


                                                                                       Stop
             Knowledge Discovery                                                                 Subject Enrichment

              A Decision box always divides a flowchart into two parts. As the number of decision boxes
              in the flowchart increases, the different paths the flowchart takes may also increase. But
              they all must end before the Stop box.


            Example 4: Write an algorithm and draw a flowchart to find the smaller of two numbers
            A and B.

                            Algorithm                                           Flowchart
             Step 1: Read the two number A and B.                                  Start



             Step 2:  If A = B, display ‘Both numbers                          Read A and B
                      are equal’, else                                           Is A = B?  Yes


                                                                                     No
                                                                                                     Print
             Step 3:  If A < B, display ‘A is smaller’,                    No                 ‘Numbers are equal’
                      else display ‘B is smaller’.                               Is A < B?
                                                                                      Yes
                                                                   Print           Print
                                                                ‘B is smaller’
                                                                                ‘A is smaller’

                                                                                   Stop


              Try This                                                                            Computational Skills

              Revise the algorithm for calling your friend to show what needs to be done if no one
              picks up the phone when you call. Draw the flowchart for the revised algorithm.


                                                                                                                 91
   88   89   90   91   92   93   94   95   96   97   98