Page 78 - 2502_Pakistan-kifayat_C-8
P. 78

Another example of using multiple conditions would be checking whether a person has a ticket. If not,
              check if the person is a VIP. If either condition is true, display "Entry Allowed", otherwise, do not allow entry.

              Start

              Set hasTicket = TRUE

              Set isVIP = FALSE
              If hasTicket = TRUE OR isVIP = TRUE Then

                  Print "Entry Allowed"

              End


                       Double Tap                                                       Century   #Critical Thinking
                                                                                          21 st
                                                                                         Skills

                     Write the result for the following conditions if num1 is 200 and num2 is 400:

                       Start                           Start                           Start
                       If (num1 > 250) OR              If (num1 > 250) AND             If (num1 < 250)
                       (num2 > 250) Then               (num2 > 250) Then               Then
                           Print "TEA"                     Print "TEA"                     Print "TEA"
                       Else                            Else                            Else
                           Print "COFFEE"                  Print "COFFEE"                  Print "COFFEE"
                       End                             End                             End









                   REPEAT AND FOREVER LOOPS


              Loops are used when we need to repeat actions without writing the same code again and again. They
              help in saving time, reducing errors, and making the program shorter and cleaner.
              Repeat Loop


              A Repeat loop is used to repeat a set of actions a fixed number of times. It helps simplify the code when
              the number of repetitions is known in advance.
              For example:


              Start
              Repeat (5)

                  Move (10) steps

              End






                  76  Premium Edition-VIII
   73   74   75   76   77   78   79   80   81   82   83