NAND and NOR logic gate

Logic Gate

Logic Gate: NAND

The logic gate NAND takes two or more input and works as per the following truth table.

i.e., if both the input A and B are 1 or TRUE then the output is 1 or TRUE; otherwise it is 0 or FALSE

NAND in code

We create a NAND using && and ! in programming language like C, C++, Java, JavaScript, Php etc. So, if we are given an if-statement then the code inside the if block will not be executed if both the variables (expression) are true.

Logic Gate: NOR

The logic gate NOR takes two or more input and works as per the following truth table.

i.e., if both the input A and B are 0 or FALSE then the output is 1 or TRUE otherwise it is 0 or FALSE.

NOR in code

We create a NOR using || and ! in programming language like C, C++, Java, JavaScript, Php etc. So, if we are given an if-statement then the code inside the if block will be executed if both the variables (expression) are false.