Page 163 - Computer
P. 163

Activity 8.5                         which instructions are executed, enabling
                                                      them to make decisions and repeat actions
             Study the rules for writing algorithms   as needed. There are three basic types     Computer Science
             and pseudocode, then do the              of  control  structures  that  flowcharts
        FOR ONLINE READING ONLY
             following:                               and pseudocode operations employ. In
              1.  Write  an  algorithm  to  find  the   drawing flowcharts, control structures can
                                                      be used to represent control of the process
                 area of a circle of radius r. Then,   flow in terms of sequence, selection, and
                 represent it using pseudocode.       iteration, as shown in Figure 8.7.
              2.  Write an algorithm to read three
                 numbers and find their sum and then,   Sequence    Selection     Iteration
                 represent it using pseudocodes.
                                                                    T                     F
              3.  Write an algorithm to convert                                         T
                 temperature from Fahrenheit to                          F
                 Celsius and then represent it using
                 pseudocode.


                                                             Figure 8.7: Control structures
                            Questions

                                                      Sequence control structure in
              1.  Did you face any challenges         flowcharts
                 relating the rules to the formulars,   The computer reads instructions from
                 operations, and processes? How did   a program file line by line sequentially,
                 you manage to interpret the rules    starting  from  the  first  line.  Examples
                 of an algorithm?                     from real  life  include  adding  numbers

              2.  Which task among the three in       or any action with a series of steps
                 Activity 8.5 is most challenging?    before termination. Consider your dress
                 Explain the challenges you faced     before leaving for school.  There  are
                 compared to others and how you       approximately  four  phases that  make
                 solved them.                         up a sequence structure:  putting  on
                                                      underwear, putting on trousers or skirt,
                                                      putting on socks, and putting on a pair
            Control  structures  in  flowcharts
            and pseudocode                            of shoes.
            Control structures are essential components   The following example illustrates the
            in programming that dictate how an        flowchart  using  a  sequential  control
            execution of a program flows. They assist   structure for an algorithm to add two
            programmers in controlling the order in   numbers, as shown in Figure 8.8.


                                                  155
              Student’s Book  Form One
   158   159   160   161   162   163   164   165   166   167   168