+ 1
Why is this false?
int i = 5,j =7 k=9 j<5 || i <=7 && k==10;
8 Respuestas
+ 18
@Samira
Let x be true,
x && !x
true && !true
true && false
false
Let x be false,
x && !x
false && !false
false && true
false
This means that x && !x will always be false.
+ 17
When we substitute the variables for their value instances:
7 < 5 || 5 <= 7 && 9 == 10
Remember that && has higher precedence than ||, hence:
false || true && false
false || false
false
+ 9
int x = 3;
if(x && !x) cout << "true";
always be false
3 is true
!3 is false
So
(true && false)
+ 8
Because k is not 10, simple as that.
&& means AND
|| means OR
AND I need k to be 10.
+ 8
Ah......really?
I think it was j<5 make it return false
After I flip it into j>5 condition return true
+ 5
AND operator has a higher precedence than OR operator
http://en.cppreference.com/w/cpp/language/operator_precedence
j(7)<5 || (i(5) <= 7 && k(9) == 10)
j(7)<5 || (true && false)
false || false
false
+ 1
Thank you all so much for helping!!
Why would something like this:
x && !x
be false then??
+ 1
Thank you all soo much! That was very helpful, I appreciate it :D