Hi, I'm going through the C-tutorial(beginner) and I want to know if I have understand it right.
Code:
A. !( 1 || 0 ) ANSWER: 0
Isnt really hard. (1 OR 0 is true) = false in this case.
Code:
B. !( 1 || 1 && 0 ) ANSWER: 0 (AND is evaluated before OR)
C. !( ( 1 || 0 ) && 0 ) ANSWER: 1 (Parenthesis are useful)
These two I dont understand so well.
Code:
B. !( 1 || 1 && 0 )
&& are operated before || so 1 && 0 is false because both numbers must be true. But what happens after that? Now we have
1 || FALSE and FALSE replaces 1 && 0. Could someone explain this? I was thinking if it would look like this after the &&-operation is done:
1 || 0 - the zero replaces the 1 && 0 wich was false. Am I thinking right?
And the last one:
C. !( ( 1 || 0 ) && 0 ) ANSWER: 1 (Parenthesis are useful)
the 1 || 0 is operated and is true(1) Then 1 && 0 is operated wich is false. The NOT-operator inverts this to true.