Page 51 - CloudGPT_C7_Flipbook
P. 51

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              Is the day is
                                    Tuesday AND the     No     Thursday AND the   No      Do not
                                     time is between            time is 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   49
   46   47   48   49   50   51   52   53   54   55   56