Page 44 - IT_V5.0_Class7
P. 44

Step 3:  If MARKS >= 75 then
                                Display Result: Distinction

                            Else If MARKS >= 50 and MARKS <75 then
                                Display Result: Pass
                            Else
                       Display Result: Fail

                  Step 4:  Stop
                  Repetition

                  This structure is used for looping, i.e., repeatedly executing a certain block of statements. For example,
                  if we have to calculate the percentage for 5 students, we can repeat the following steps 5 times:
                  1.  Input marks for English, Hindi, and Maths of Student 1.
                  2.  Total the marks.
                  3.  Calculate the percentage.
                  4.  Display the percentage.

                  5.  Repeat the steps 1 to 4 to calculate the percentage of other students.
                  Let us write some algorithms based on repetition control structure.
                  Algorithm 9: Write an algorithm to display the even numbers from 2 to 10.
                  Step 1:  Start
                  Step 2:  Set a variable NUM = 2.

                  Step 3:  Repeat the following steps until NUM reaches 10.
                                Display the value of NUM.
                                   Change NUM = NUM + 2.
                                   Go to Step 3.
                  Step 4:  Stop
                  Algorithm 10: Write an algorithm to display the square of the first five natural numbers.
                  Step 1:  Start

                  Step 2:  Set a variable NUM = 1.
                  Step 3:  Repeat the following steps until NUM reaches 5.
                                                                       Boost Bits
                                Display NUM*NUM
                                Change NUM = NUM + 1.
                                                                 There are online tools available that can
                                Go to Step 3.
                                                                 convert algorithms written in pseudocode or
                  Step 4:  Stop
                                                                 plain text into code in specific programming
                                                                 languages.

                     FLOWCHARTS

                  A flowchart is a graphical representation of an algorithm. It makes use of symbols that are connected
                  through arrows to show the direction of flow of information. It has been proven scientifically that
                  visuals have more impact on the human brain as compared to text. So flowcharts are preferred
                  over algorithms for solving a problem.




                    42    Information Technology (V5.0)-VII
   39   40   41   42   43   44   45   46   47   48   49