This post is also available in: हिन्दी (Hindi) العربية (Arabic)

In our day-to-day life, we use the decimal number system. But calculators and computers store numbers (0 – 9) as long strings of zeros and ones in a form called binary code. Operations are performed on these numbers using Logic Gates.

But how can computers add, subtract, multiply, and divide using nothing but electric circuits? All these operations are performed by Logic Gates. Let’s find out what are Logic Gates.

## What are Logic Gates?

Calculators and computers do this using clever electronic circuits called **logic gates**.

Logic gates are the basic building blocks of any digital system. It is an electronic circuit having one or more than one input and only one output. The relationship between the input and the output is based on a certain logic. Based on this, logic gates are named as AND gate, OR gate, NOT gate, etc.

## Basic Logic Gates

There are three types of basic logic gates:

**AND:**It gives an output 1, only if both the inputs are 1.

Truth Table of AND gate:

A | B | A AND B |

0 | 0 | 0 |

0 | 1 | 0 |

1 | 0 | 0 |

1 | 1 | 1 |

2. **OR:** It gives an output 1 if any of the inputs is 1.

Truth Table of OR gate

A | B | A OR B |

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 1 |

3. **NOT:** It reverses the input.

Truth table of NOT gate

A | NOT A |

0 | 1 |

1 | 0 |

## Combinational Logic Gates

**NAND**: It is a combination of NOT and AND gates.

Truth table of NAND gate

A | B | A AND B | NOT(A AND B) / A NAND B |

0 | 0 | 0 | 1 |

0 | 1 | 0 | 1 |

1 | 0 | 0 | 1 |

1 | 1 | 1 | 0 |

2. **NOR**: It is a combination of NOT and OR gates.

Truth table of NOR gate

A | B | A OR B | NOT(A OR B) / A NOR B |

0 | 0 | 0 | 1 |

0 | 1 | 1 | 0 |

1 | 0 | 1 | 0 |

1 | 1 | 1 | 0 |

## Some More Logic Gates

**XOR**: XOR or Ex-OR gate is a special type of gate. It can be used in the half adder, full adder, and subtractor. The exclusive-OR gate is abbreviated as EX-OR gate or sometimes as X-OR gate. For like inputs, the out is 0, and for unlike inputs the out is 1.

Truth table of XOR gate

A | B | A XOR B |

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 0 |

2. **XNOR**: XNOR gate is a special type of gate. It can be used in the half adder, full adder, and subtractor. The exclusive-NOR gate is abbreviated as EX-NOR gate or sometimes as X-NOR gate.

A | B | A XNOR B |

0 | 0 | 1 |

0 | 1 | 0 |

1 | 0 | 0 |

1 | 1 | 1 |