Page 43 - IT_V5.0_Class7
P. 43

Step 3:  Convert temp to Celsius = (temp - 32) * 5 / 9.
                 Step 4:  Display Celsius.

                 Step 5:  Stop
                 Selection

                 This structure enables the algorithm to make decisions based on a condition. If the condition is
                 true, a specific block of instructions is executed. If the condition is false, an alternative block of
                 instructions is followed. For example, consider a situation where we check a condition: Eligible
                 for Vote if the age is 18 or above.

                 Input age of the person.
                 If age is 18 or above, then
                    Display "Eligible to vote"
                 Else
                    Display "Not eligible to vote"

                 Stop
                 Let us write some algorithm based on selection control structure.
                 Algorithm 6: Write an algorithm to  check if a number is divisible by 5.
                 Step 1:   Start
                 Step 2:  Input NUM.
                 Step 3:  If NUM%5 is equal to 0 then
                               Display NUM is divisible by 5.
                           Else
                               Display NUM is not divisible by 5
                 Step 4:  Stop
                 Algorithm 7: Write an algorithm to input a number and check if a number is between 1 and 100.
                 Step 1:  Start
                 Step 2:  Input NUM.

                 Step 3:  If NUM >= 1 and NUM<= 100, then
                              Display "NUM is between 1 and 100."
                           Else
                              Display "NUM is not between 1 and 100."
                 Step 4:   Stop
                 Algorithm 8: Write an algorithm to input marks and display the result based on Pass, Fail, and
                 Distinction criteria

                                                       Marks             Grade

                                                   >=75              Distinction
                                                   >=50 and <75      Pass
                                                   <50               FAIL

                 Step 1:  Start

                 Step 2:  Input MARKS.



                                                                                       Algorithm and Flowchart   41
   38   39   40   41   42   43   44   45   46   47   48