Logical Operations - Truth Tables
Truth Tables

A truth table for a logical operation defines the outputs for all possible combinations of input.

NOT :
The output is the opposite of the input.
Input (A) Output (NOT A)
0 1
1 0

 

AND :

The output is 1 only if A and B are both 1.

Input (A)

Input (B) Output (A AND B)
0 0 0
0 1 0
1 0 0
1 1 1

 

OR :

The output is 1 if either A or B is 1

Input (A)

Input (B) Output (A OR B)
0 0 0
0 1 1
1 0 1
1 1 1

 

XOR :

The output is 1 if either A or B is 1 but not both

Input (A)

Input (B) Output (A XOR B)
0 0 0
0 1 1
1 0 1
1 1 0

 

 
  Logical functions are used widely in programming algorithms. It is not uncommon to find programming lines such as...

If ((A = "Jones") AND NOT((B = "Tom") OR (A="John")) then ....