## What is Computer Logic

A logic gate is an elementary building block of a digital circuit. Most logic gates have two inputs and one output. At any given moment, every terminal is in one of the two binary conditions low (0) or high (1), represented by different voltage levels. The logic state of a terminal can, and generally does, change often, as the circuit processes data. In most logic gates, the low state is approximately zero volts (0 V), while the high state is approximately five volts positive (+5 V).

There are six basic logic gates: AND, OR, XOR, NOT, NAND, and NOR.

## What are Truth Tables?

In computer logic a Truth Table is simply a table showing all the potential outputs of a circuit using Logic Gates. Representing the inputs and outputs with 0 or 1 I.e Binary, it can show all outcomes of a gate and can be expressed with a Boolean expression.

The table below is an example of a simple AND gate, with two inputs A and B, and one output C.

 A B C 0 0 0 0 1 0 1 0 0 1 1 1

## Types of Logic Gates

### AND Gate

The truth table would look like this:

A B Q
0 0 0
0 1 0
1 0 0
1 1 1

The Boolean expression is written as Q = A.B

### OR Gate

The truth table would look like this:

A B Q
0 0 0
0 1 1
1 0 1
1 1 1

The Boolean expression is written as Q = A+B

### XOR Gate

The XOR gate is indicated with the extra curved line to the left of the main shape.

The truth table would read like this:

A B Q
0 0 0
0 1 1
1 0 1
1 1 0

The Boolean expression is written as Q = A  XOR  B

### NOT Gate

If A is the input and Q is the output, the truth table looks like this:

A Q
1 0
0 1

The Boolean expression is written as Q = A

### NAND Gate

The NAND gate is the same as an AND followed by a NOT, so is the inverse of an AND gate.

A B Y
0 0 1
0 1 1
1 0 1
1 1 0

The Boolean Expression is written as Y = A.B

### NOR Gate

The NOR gate is the same as an AOR followed by a NOT, so is the inverse of an OR gate.

A B Y
0 0 1
0 1 0
1 0 0
1 1 0

Boolean Expression Y = A+B