Page 71 - CG_v2.1_flipBooks_class_6
P. 71

Advantages of an Algorithm


                 l   Easy to understand.
                 l   Follows a certain protocol.

                 l   A step-by-step explanation of how to solve a certain problem.
                                                                                      Information Literacy
                       Quest                                                          Technology Literacy


                      Write an algorithm to calculate the area of a triangle.

















                 Representation of an Algorithm

                 Algorithm can be represented in two ways:


                                                Representation of Algorithm





                                    Flowchart                              Pseudocode

                                                            BEGIN
                                      Start
                                                                // Input: Get the user's age
                                                                DISPLAY "Enter your age:"
                                    Read Age
                                                                READ age

                                                                // Check if the age is 18 or above
                                Yes     If     No
                                     Age>=18                    IF age >= 18 THEN
                                                                    DISPLAY "You are eligible for a driving license."
                          Show "Eligible      Show "Not
                             to vote"      eligible to vote"      ELSE

                                                                    DISPLAY "You are not eligible for a driving license."
                                                                END IF
                                       End                  END



                 Flowchart

                 A flowchart is a diagrammatic representation of a step-by-step plan which is followed to solve a
                 problem.

                                                                                  Algorithm and Pseudocode    69
   66   67   68   69   70   71   72   73   74   75   76