Trusted answers to developer questions

Logic gates

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

Logic gates are the fundamental building blocks of circuits. Circuits are used to perform operations in a computer system. They are mainly used in the arithmetic logic unit known as ALU.

There are 5 main logic gates.

  • AND
  • OR
  • NOT
  • NOR
  • NAND

These logic gates take inputs and give a single output.

AND gate

The AND gate gives 11 as an output when all the inputs are 11. If there are any 00's in the input, the AND gate gives 00 as an output. Think of it as multiplication between 00 and 11.

widget

OR gate

The OR gate gives 11 as an output when at least one of the inputs is 11. If all inputs are 00, the output is 00. Think of it as addition between 00 and 11.

widget

NOT gate

NOT is a simple gate that takes in a single input and reverses its value. Whatever the input, this gate outputs the opposite (i.e., if 11 is inputted, it gives 00 as the output).

widget

NOR gate

The NOR gate is opposite to the OR gate. It gives 11 as an output whenever all inputs are 00 (i.e., 11 is not an input).

widget

NAND gate

The NAND gate gives 11 as an output when there is a single 00 as an input. It gives 00 as an output whenever all inputs are 11. NAND is opposite of AND.

widget

RELATED TAGS

logic
gates
and
or
not
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?