Page 158 - Computer
P. 158

Computer Science  (vii) Include start and end points:   Step 2:   Define the processes or
               Include a starting symbol (usually

                                                              actions, that is, adding or
               an oval shape) to represent the
                                                              calculating the sum of the
               beginning of the process and an
                                                              two numbers.
               ending symbol (also an oval) to
        FOR ONLINE READING ONLY
                                                    Step 3:   Identify the output. Output
               represent the conclusion of the
                                                              is the sum.
               process.
           (viii)  Add connectors:                  Step 4:   Identify the standard symbols
               Employ link points (small circles) to          used in the problem.
               join different parts of the flowchart   Step 5:   Draw a flowchart, as shown
               together, especially when the                  in Figure 8.5.
               flowchart extends across multiple
               pages.                                             Start


                   Example 1

           Write an algorithm for calculating the             Input N1, N2
           sum of any two numbers entered by the
           user and then draw a flowchart for it.

           Solution:                                        SUM =  N1 + N2
           Algorithm for adding two numbers:
           Step 1: Start by identifying two
                    numbers, e.g., N1 and N2.                  Output SUM
           Step 2:   Input or write the first number
                    N1.
           Step 3: Input or write the second                    End/Stop
                    number N2.
           Step 4:   Add the number N1 and                Figure 8.5: Flow chart for the sum of two
                    number N2, i.e., N1+N2.                          numbers

           Step 5:   Give the answer or output the
                    sum, i.e., Sum= N1 + N2.                 Example 2
           Step 6:   End the process.               Suppose we want to write an algorithm

                                                    to  find  the  square  of  a  number  and
           The following are steps for drawing      represent it using a flowchart.
           the  flowchart  that  will  calculate  the
           sum of any two numbers:                  Before developing the algorithm, you
           Step 1: Identify the inputs (two         should first identify the input, process,
                    numbers, for example, N1        and output. In this case, input will be
                    and N2),                        the number whose square is required.


                                               150
                                                                  for Secondary Schools
   153   154   155   156   157   158   159   160   161   162   163