Pea apres 5 ans

Comment

Author: Admin | 2025-04-28

Int main(){ int a[5] = { 1, 0, 1, 0, 1 }; int b[5] = { 0, 1, 1, 0, 0 }; int i, ans; for (i = 0; i 5; i++) { ans = !(a[i] * b[i]); printf("\n %d NAND %d = %d", a[i], b[i], ans); }}Output 1 NAND 0 = 1 0 NAND 1 = 1 1 NAND 1 = 0 0 NAND 0 = 1 1 NAND 0 = 14. NOR Gate The NOR gate (negated OR) gives an output of 1 if both inputs are 0, it gives 1 otherwise. Below are the programs to implement NOR gate using various methods: Using + Operator. Using if else. + Operator. // C program implementing the NOR gate#include #include int main(){ int a[5] = { 1, 0, 1, 0, 1 }; int b[5] = { 0, 1, 1, 0, 0 }; int i, ans; for (i = 0; i 5; i++) { ans = !(a[i] + b[i]); printf("\n %d NOR %d = %d", a[i], b[i], ans); }} If-Else // C program implementing the NOR gate#include #include int main(){ int a[5] = { 1, 0, 1, 0, 1 }; int b[5] = { 0, 1, 1, 0, 0 }; int i, ans; for (i = 0; i 5; i++) { if (a[i] == 0 && b[i] == 0) ans = 1; else ans = 0; printf("\n %d NOR %d = %d", a[i], b[i], ans); }}Output 1 NOR 0 = 0 0 NOR 1 = 0 1 NOR 1 = 0 0 NOR 0 = 1 1 NOR 0 = 05. NOT Gate It acts as an inverter. It takes only one input. If the input is given as 1, it will invert the result as 0 and vice-versa. Below are the programs to implement NOT gate using various methods:

Add Comment