Page 91 - Code_GPT_Class_8
P. 91

But If I am not able to achieve any of                 Ah! I am afraid,
                  these conditions, he will not do so.                      he won't be
                                                                          happy if I don't
                                                                         fulfil his multiple
                                                                            conditions.
















                                                      What if you
                                                      achieve either
                                                      of the two?

                  Test Your Knowledge                                                         21 st  Century   #Critical Thinking
                                                                                                  Skills
                   Write the output of the following statements:

                    1.  age = 25                                          2.  marks = 25
                      IF age >= 18 THEN                                     IF marks >= 60 THEN
                          PRINT "You can vote"                                  PRINT "First Division"
                      ELSE                                                  ELSE
                          PRINT "You cannot vote"                               PRINT "You can do better!

                                                                           Assume that the value of marks
                        Assume that the age is 15.                                     is 85.





                 We learnt about writing algorithms for a program and using conditional statements in a program.
                 Let us learn multiple conditions and loops in a program.


                 MULTIPLE CONDITIONS IN A PROGRAM

                 Conditional  statements are used in a program to                 Start
                 instruct the computer to make a decision. The result
                 of the condition will always be either true or false.
                 The program executes the statements written after ‘if’             if        False
                 when the condition is true. If it is false, the statements     condition
                 written after ‘else’ will be executed.                        True


                                                                            Statement inside if    Statement inside else
                                                                             block will execute      block will execute



                                                                                  Stop




                                                                                          Algorithmic Intelligence  89
   86   87   88   89   90   91   92   93   94   95   96