Page 49 - CloudGPT_C7_Flipbook
P. 49

OR Operator
                 OR operator is used to check if either one of two or more conditions is TRUE or Yes.

                 In OR operator:

                    If any of the condition is true, the operator returns TRUE or Yes.
                    If all the conditions are false, the operator returns FALSE or No.


                                                                                                       Critical Thinking
                  Example 2: You should go to play outside for an hour, if you have
                  completed your homework , or the time is past 6 PM. Otherwise, you
                  should not go outside to play.



                 Conditions:  1.  Have you completed your homework?

                               2.  Is the time past 6 PM?
                 Decision: Should you go to play outside for an hour or not?


                 Answer: Yes, past 6 PM you can go to play outside for an hour, if you have completed your
                 homework, if you have not completed your homework then complete it.

                 Pseudocode:

                      Program Start
                      IF  (You have completed your homework) OR (The time is past 6 PM)
                      THEN

                            Go to play outside for an hour
                      ELSE
                            Complete your homework

                      Program End
                 Possible combinations of the example 2:

                                Condition 1                          Condition 2                   Decision
                       (Have you completed your                   (Is the time past          (Should you go to

                                homework?)                              6 PM?)                      play?)
                                     Yes                                  Yes                         Yes
                                     Yes                                  No                          Yes

                                     No                                   Yes                         Yes
                                     No                                   No                          No

                 NOT Operator

                 NOT operator is used to reverse or negate a condition.

                                                                                     Control with Conditionals   47
   44   45   46   47   48   49   50   51   52   53   54