1 / 24

2. Logical Operations

Learn how to use AND, OR, NOT, and XOR logical operators in programming. Explore truth tables and their applications for problem-solving.

rusin
Download Presentation

2. Logical Operations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2. Logical Operations

  2. 2.1.1 - Use of AND, OR, NOT and XOR logical operators, combinations of these, and their application in appropriate truth tables to solve problems. • Logical operators are used in programming. It is not unusual to find a code such as: • IF A = 1 AND B = 1 THEN • IF A = 1 OR B = 1 THEN  • The rules for combining logical expressions are usually written down as tables that list all the possible outcomes. These tables are known as truth tables.

  3. 2.1.1 - Use of AND, OR, NOT and XOR logical operators, combinations of these, and their application in appropriate truth tables to solve problems. • NOT • The NOT logical operator has only one input and one output. The output is the opposite of the input.

  4. 2.1.1 - Use of AND, OR, NOT and XOR logical operators, combinations of these, and their application in appropriate truth tables to solve problems. • AND • The AND logical operator has two inputs and one output. The output is 1 only if A and B are both 1.

  5. 2.1.1 - Use of AND, OR, NOT and XOR logical operators, combinations of these, and their application in appropriate truth tables to solve problems. • OR • The OR logical operator has two inputs and one output. The output is 1 if either A or B is 1.

  6. 2.1.1 - Use of AND, OR, NOT and XOR logical operators, combinations of these, and their application in appropriate truth tables to solve problems. • XOR • The XOR logical operator has two inputs and one output. The output is 1 only if A and B are different.

  7. Logical operations Logical operations can be used in control systems. For example, a control system that closes the windows on a commercial greenhouse when at least one of the following conditions is true: • the wind speed rises above 12 km per hour. • it is raining. would use the logical operator OR. On the other hand, a control system that turns on a sprinkler system in a field when both of the following conditions are true: • the temperature rises above 25° C • it has not rained in the last five days would use the logical operator AND.

  8. 2.2 - Boolean logic

  9. 2.2.1 - Simplify Boolean expressions using Boolean identities and rules. • Notation The logical operators that are going to be used are NOT, AND, OR and XOR. Boolean algebra uses the following notation to represent the input variables and operators:

  10. 2.2.1 - Simplifying Boolean expressions using Boolean identities and rules. • Laws of Boolean Algebra • Boolean Algebra is a system of mathematics based on logic that has its own set of rules or laws that can be used to simplify Boolean expressions: • Annulment Law • Identity Law • Idempotent Law • Complement Law • Commutative Law • Double Complement Law • Distributive Law • Absorptive law • Associative Law

  11. 2.2.1 - Simplifying Boolean expressions using Boolean identities and rules. • Annulment Law • A.0 = 0 A variable AND 0 is always equal to 0 • A + 1 = 1 A variable OR 1 is always equal to 1

  12. Identity Law • A + 0 = A A variable OR 0 is always equal to the variable • A.1 = A A variable AND 1 is always equal to the variable

  13. Idempotent Law • A + A = A A.A = A

  14. Complement Law • A.Ā = 0 • A + Ā = 1

  15. Commutative Law • A.B = B.A A + B = B + A

  16. Distributive Law • A.(B + C) = A.B + A.C (OR Distributive law)

  17. Distributive Law • A + (B.C) = (A + B).(A + C) (AND Distributive law)

  18. Absorptive Law • A + (A.B) = A (OR Absorption law)

  19. Absorptive Law • A.(A + B) = A (AND Absorption law)

  20. Associative Law • A + (B + C) = (A + B) + C = A + B + C

  21. Associative Law • A(B.C) = (A.B)C = A.B.C

More Related