Page 50 - Touchcode_C6_Flipbook
P. 50

Logical Operator





                        AND                                        OR                                      NOT


                  AND Operator

                  AND operator is used to check if two or more conditions are TRUE or FALSE.
                  In AND operator:

                      If all the conditions are true, the operator returns TRUE or Yes.
                      If any one of the conditions fails, the operator returns FALSE or No.
                                                                                                        Life Skills & Values

                    Example 1: You can play after 6 PM for an hour only after you have
                    completed your homework.

                  Condition:
                  1.  Have you completed your homework?

                  2.  Is the time past 6 PM?
                  Decision: Should you go to play or not?
                  Answer: If the time is past 6 PM and you have completed your homework, you can go out
                  to play.
                  If you have not completed your homework, you should finish it first.

                  Pseudocode:
                       Program Start
                       IF (Homework completed) AND (Time is past 6 PM)
                       THEN
                            Go to play outside for an hour
                       ELSE
                            Complete your homework

                       Program End
                  Possible combinations of the example 1:

                                 Condition 1                          Condition 2                   Decision
                        (Have you completed your                  (Is the time past 6         (Should you go to
                                 homework?)                               PM?)                       play?)
                                      Yes                                  Yes                         Yes
                                      Yes                                  No                          No

                                      No                                   Yes                         No
                                      No                                   No                          No


                   48     Touchcode-VI
   45   46   47   48   49   50   51   52   53   54   55