diff options
| author | mo khan <mo.khan@gmail.com> | 2020-07-22 11:06:01 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-07-22 11:06:01 -0600 |
| commit | 976a848640034f19fc4203f02928c2be734aafb1 (patch) | |
| tree | 99c3713bb768c6b1aaa11be9c6a25b346c8d7c3d | |
| parent | 67bc0208e95a61c92977031cd873c6e5ecf71b9e (diff) | |
Episode 3: Lie Detector Tests
| -rw-r--r-- | README.md | 54 | ||||
| -rw-r--r-- | main.c | 31 |
2 files changed, 64 insertions, 21 deletions
@@ -92,3 +92,57 @@ rinse and repeat printf("true\n"); } ``` + +# conditions and logic + + + + +# polygraphs + +* lie detector + + +question: + +Q: Are you 36 years old? +A: no + +* FAIL: this is not the truth + * the exam is over + +Q: Are you a male? +A: yes + +* PASS: this is the truth + * continue to ask the next question + +* true | false +* yes | no + + + +Truth tables + +* true: 1 +* false: 0 + +AND + +| - | - | ------ | +| x | y | result | +| - | - | ------ | +| 0 | 0 | 0 | +| 0 | 1 | 0 | +| 1 | 0 | 0 | +| 1 | 1 | 1 | + +OR + +| - | - | ------ | +| x | y | result | +| - | - | ------ | +| 0 | 0 | 0 | +| 0 | 1 | 1 | +| 1 | 0 | 1 | +| 1 | 1 | 1 | @@ -1,33 +1,22 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> int main(int argc, char *argv[]) { - char bike_rack[8]; - for (int i = 0; i < 8; i = i + 1) + // AND && + // OR || + // + int age = 30; + + if (/* */) { - bike_rack[i] = '\0'; // NULL -> nothing + printf("Fly to Hawaii\n"); } - - // rack: [0, 1, 2, 3] - // mo: 'm' - // om: 'o' - // bo: 'b' - // yo: 'y' - - bike_rack[0] = 'm'; - /*bike_rack[1] = 'o';*/ - /*bike_rack[2] = 'b';*/ - bike_rack[3] = 'y'; - - for (int i = 0; i < 8; i = i + 1) + else { - int bike = bike_rack[i]; - printf("bike rack slot %d: %c\n", i, bike); + printf("Camp in the back yard\n"); } - - printf("\n"); - return 0; } // 1. compile: c -> machine |
