Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main (int argc, char **argv){
- /*
- De Morgan's Laws
- not (A or B) = not A and not B
- not (A and B) = not A or not B
- */
- printf("not (A or B) = not A and not B\n");
- printf("not (A and B) = not A or not B\n");
- printf("!(0||0): %s\t", !(0||0) ? "true" : "false");
- printf("!0&&!0: %s\n", !0&&!0 ? "true" : "false");
- printf("!(0||1): %s\t", !(0||1) ? "true" : "false");
- printf("!0&&!1: %s\n", !0&&!1 ? "true" : "false");
- printf("!(1||0): %s\t", !(1||0) ? "true" : "false");
- printf("!1&&!0: %s\n", !1&&!0 ? "true" : "false");
- printf("!(1||1): %s\t", !(1||1) ? "true" : "false");
- printf("!1&&!1: %s\n", !1&&!1 ? "true" : "false");
- printf("!(0&&0): %s\t", !(0&&0) ? "true" : "false");
- printf("!0||!0: %s\n", !0||!0 ? "true" : "false");
- printf("!(0&&1): %s\t", !(0&&1) ? "true" : "false");
- printf("!0||!1: %s\n", !0||!1 ? "true" : "false");
- printf("!(1&&0): %s\t", !(1&&0) ? "true" : "false");
- printf("!1||!0: %s\n", !1||!0 ? "true" : "false");
- printf("!(1&&1): %s\t", !(1&&1) ? "true" : "false");
- printf("!1||!1: %s\n", !1||!1 ? "true" : "false");
- return 0;
- }
- /*
- output:
- not (A or B) = not A and not B
- not (A and B) = not A or not B
- !(0||0): true !0&&!0: true
- !(0||1): false !0&&!1: false
- !(1||0): false !1&&!0: false
- !(1||1): false !1&&!1: false
- !(0&&0): true !0||!0: true
- !(0&&1): true !0||!1: true
- !(1&&0): true !1||!0: true
- !(1&&1): false !1||!1: false
- */
Advertisement
Add Comment
Please, Sign In to add comment