Page 53 - Touchcode_C6_Flipbook
P. 53

COMBINING LOGICAL OPERATORS
                 To create a complex expression, you  may need  to combine different  logical operators.

                 Consider an example, here we are combining AND and OR operators.
                                                                                                      Subject Enrichment

                   Example 1: You can attend your dance class on Tuesday between 12
                   PM to 2 PM or on Thursday between 4 PM to 6 PM.

                 Pseudocode:

                        Program Start

                        IF (Day is Tuesday AND (Time is 12 PM or greater AND Time is 2 PM or lesser)) OR
                        (Day is Thursday AND (Time is 4 PM or greater AND Time is 6 PM or lesser))
                        THEN
                               Attend your dance class

                        ELSE
                               Do not attend your dance class
                        Program End

                 Flowchart:

                                          Start










                                        Is the day                Is the day
                                   Tuesday AND is the   No     Thursday AND is    No      Do not
                                      time between             the time between         attend your
                                    12 PM and 2 PM?            4 PM and  6 PM?          dance class








                                              Yes

                                                         Yes
                                       Attend your
                                       dance class






                                          End

                                                                                     Control with Conditionals   51
   48   49   50   51   52   53   54   55   56   57   58