Page 362 - Ai_417_V3.0_C9_Flipbook
P. 362

Step 1   Start
               Step 2   count=1

               Step 3   if count <=10 goto Step 4 else goto step 10
               Step 4   Input Eng,Science, Math
               Step 5   Total= Eng+Science+Math
               Step 6   Percentage = (Total / Maximum_Marks) * 100

               Step 7   Display Percentage
               Step 8   count=count+1
               Step 9   Goto Step 3
               Step 10  Stop


                       Algorithm


              An algorithm is a step-by-step approach to identify and solve a problem in a finite amount of time. It is used in the
              problem-solving phase of any programming task and helps in defining clear instructions in sequence. An algorithm
              uses simple English-like statements to represent the steps of a program. There may be more than one way to solve
              any problem, so there may be more than one algorithm for a given problem. It must terminate after a finite number
              of steps. Once we have an algorithm, we can translate it into a computer program in any programming language.




                            Brainy Fact


                   The word 'algorithm' come from the name of a Persian mathematician called Al-Khwārizmī.




              Writing an Algorithm

              Let us do an activity of writing an algorithm for making cucumber and tomato sandwich:

               Step 1   Take a few slices of tomato and a cucumber.
               Step 2   Take two slices of multigrain bread.

               Step 3   Put tomato sauce on one slice of bread.

               Step 4   Put cheese spread on the other slice of bread.

               Step 5   Place a few slices of tomato and cucumber between the two slices of bread.

               Step 6   Cut the sandwich into two halves and serve it.

              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 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.



                    360     Touchpad Artificial Intelligence (Ver. 3.0)-IX
   357   358   359   360   361   362   363   364   365   366   367