Search code examples
if-statementlogicconditional-statementstruthtable

need a conditional statement for desired output


I need to write a conditional tatement in IF class by using three variable to get some desired output, i have tried many logics with that three variable to get the desired output which i can use in if class but i couldn't succeed, hope anyone can help me with this,
Thank you
here us the conditional table i need
A                B            C            result
False      False      False          False
True        False        False        True
True        True        False         False
True        True        True            True
True        True        False          False


Solution

  • The result is only true if

    1) A is true and B & C are false
    2) A, B, and C are true

    In other words:

    if((A & !B & !C) | (A & B & C)){
      print('true')
    }
    

    The third and fifth row in your table are equal by the way.