Page 110 - TP_Play_V2.1_class8
P. 110

09                                     ALGORITHMIC INTELLIGENCE
















                            to learn about:

                                    Multiple Conditions in a Program           Loops in a Program





                  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
                                                                                Start
                  to instruct the computer to make a decision. The
                  result of the condition will always be either true
                                                                                  if        False
                  or false. The program executes the statements
                                                                              condition
                  written after ‘if’ block when the condition is true.
                  If it is false, the statements written after ‘else’
                                                                             True
                  block will be executed.
                                                                       Statement inside if block   Statement inside else
                  However,  there  might be situations when  we              will execute          block will execute

                  need  to  check  for  multiple conditions in a
                                                                                Stop
                  program. For example, look at these programs:

                  username = "Orange"

                  password = "secure123"

                  IF username = "Orange" AND password = "secure123" THEN
                      PRINT "Access granted"

                  ELSE

                      PRINT "Access denied"


                        Access granted



                  108       Play (Ver. 2.1)-VIII
   105   106   107   108   109   110   111   112   113   114   115