Page 45 - IT_V5.0_Class8
P. 45

Some of the basic guidelines that we can follow while writing an algorithm are as follows:

                    It begins with the keyword “Start”
                    It is written using simple English-like statements.
                    It is not case-sensitive; it can be written in uppercase, lowercase, or mixed case.
                    It is usually presented in a step-by-step format, with or without step numbers.
                    It should follow a logical path, i.e., take at least one input, process the input and produce the
                    desired output.

                    It must terminate after a finite number of steps.
                    It ends with the keyword “Stop”
                 Advantages of an Algorithm

                 The advantages of an algorithm are as follows:
                    It is a step-by-step representation of a solution to a given problem.

                    It uses simple English-like statements so that it is easy to understand and write.
                    The problem is broken down into smaller pieces; hence, it is easy to convert it into a program
                    using any programming language.
                 Writing Algorithms


                 Algorithm 1: Write an algorithm for making lemonade.
                 Step 1:  Start

                 Step 2:  Collect lemons, water, sugar, jug, and stirring spoon.
                 Step 3:  Squeeze lemon juice into the jug.
                 Step 4:  Add sugar and water into the jug.
                 Step 5:  Stir until sugar is dissolved.
                 Step 6:  Add some ice into the jug.

                 Step 7:  Pour it in the glasses and serve.
                 Step 8:  Stop

                 Algorithm 2: Write an algorithm for going to school in the morning.
                 Step 1:  Start

                 Step 2:  Wake up early in the morning.
                 Step 3:  Brush your teeth and take a bath.
                 Step 4:  Get dressed for school.
                 Step 5:  Eat breakfast.

                 Step 6:  Pack your bag according to the class periods.
                 Step 7:  Go to the bus stop.
                 Step 8:  Board the bus.
                 Step 9:  Reach school and enjoy learning!

                 Step 10:  Stop





                                                                                       Algorithm and Flowchart   43
   40   41   42   43   44   45   46   47   48   49   50