+ 1
Truth Table Generator wont show correct result when user inputs Logical NOT
New in C here. The code is a simple truth table generator with only 3 columns (p q result). The program works just fine, unless when the Logical NOT operator (!) is inputted. ------------------------------------------- The output Im getting when I enter: !p&q p q !p&q F F T F T T T F F T T F ------------------------------------ My desired Output: p q !p&q F F F F T T T F F T T F This is the code: https://www.sololearn.com/en/compiler-playground/c9lN95xU1dJO
3 Réponses
+ 3
The problem stems from line 42 where sscanf is targeting the output to the wrong variables. Two of them are swapped.
After that there is more work to be done to correctly evaluate the expression that contains a '!'.
For app users, here is the link to the code:
https://sololearn.com/compiler-playground/c9lN95xU1dJO/?ref=app
+ 1
why is there a need for user input? it just complicates the code if you just want a truth table.
https://sololearn.com/compiler-playground/cgxRhfH3I14g/?ref=app
+ 1
Bob_Li That would've been great but we were required to get the user input