Page 128 - Touchpad_Plus_V3.2_Class 8
P. 128

9                     Algorithmic Intelligence

















                          Your Aim

                          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         True
                  ‘else’ block will be executed.                       Statement inside if block   Statement inside else
                                                                             will execute          block will execute
                  However,  there  might be situations when  we
                  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



               126      Plus (Ver. 3.2)-VIII
   123   124   125   126   127   128   129   130   131   132   133