Quote (NinjaSushi2 @ Mar 10 2014 01:22am)
Oh god derp. I was thinking if I should use AND. I forgot that != reverses the truths, correct?
So the && boolean works but I am confused on why. The statement is saying
Code
while (beverage is NOT equal to e && NOT equal E) return 0;
I would think it would require the use of both e and E but it compiles correctly and executes correctly. Can someone explain why?
Create a truth table out of it.
Let beverage equal A and let 'e' equal B and let 'E' equal C
Your variables would be like so
Code
A B C
0 0 0
0 0 1
0 1 0
1 0 0
0 1 1
1 0 1
1 1 1
Now solve the sub equations (NOT EQUALS)
Code
A B C A!=B A!=C
0 0 0 0 0
0 0 1 0 1
0 1 0 1 0
1 0 0 1 1
0 1 1 1 1
1 0 1 1 0
1 1 1 0 0
Now simply do your != && != table
Code
A B C A!=B A!=C (A!=B)&&(A!=C)
0 0 0 0 0 0
0 0 1 0 1 0
0 1 0 1 0 0
1 0 0 1 1 1
0 1 1 1 1 1
1 0 1 1 0 0
1 1 1 0 0 0
Now thinking back on how a while loop works (it loops as long as it is true) so as long as the states of A B C relates to 0 1 1 or 1 0 0 it will not break from the loop.
*Hopefully I got that table right, it's getting late for me*
This post was edited by AbDuCt on Mar 9 2014 11:53pm