Page 86 - 2611_SmartGPT Pro V(5.0) C-5
P. 86

WRITING AN ALGORITHM


                  Algorithm provides a step-by-step solution to the problem. Let’s write an algorithm for
                  some problems.
                  MAKING A CUP OF TEA                                  CALCULATE THE SUM OF TWO

                  Step  1   Start.                                     NUMBERS
                  Step  2    Collect  Kettle, Teabags, water,          Step  1   Start.
                            milk, sugar and cup.                       Step  2    Read  two  numbers and store

                  Step  3   Boil the water in the kettle.                        them in A and B.
                  Step  4   Pour the boiling water into the cup.       Step  3   Add two numbers A and B.

                  Step  5    Add milk, sugar and put a teabag          Step  4   Print the sum.
                            in the cup.
                                                                       Step  5   Stop.
                  Step  6   Stir the tea and the tea is ready.
                  Step  7   Stop.


                  CALCULATING THE AREA OF A CIRCLE

                  Step  1   Start.

                  Step  2    Read the radius of the circle and store it in r. (where, r is the length from the
                            centre of the circle to the edge of the circle.)

                                                                                       2
                  Step  3   Calculate the area of the circle. (Where, Area = π × r (3.14 × radius × radius))
                  Step  4   Print the area.

                  Step  5   Stop.




                            FLOWCHART


                  A flowchart is the graphical representation of a process and the logic (also referred to
                  as an algorithm) used in it. Flowcharts are used in analysing, designing, documenting or
                  managing a process or program in various fields.


                  SYMBOLS USED IN FLOWCHARTS

                  A flowchart uses specific geometrical shapes and directional arrows to draw a flow chart
                  for a particular task. A set of geometrical shapes represents the steps involved in the
                  solution process. Each shape represents a specific function, activity, or process. Directional

                  arrows are used to connect the shapes, indicating the flow of the solution.






                   84   Computer Science (V5.0)-V
   81   82   83   84   85   86   87   88   89   90   91