Ok, so I am learning c++ as a hobby and using an online tutorial and I have come to a section about logical operators !, &&, and ||. So I understand that ! is the inverse of a variable, && means both have to be true or it is false and || means only one has to be true. So it explained that but it gave these problems to solve.
Evaluate the following: 1) (true && true) || false
2) (false && true) || true
3) (false && true) || false || true
4) (5 > 6 || 4 > 3) && (7 > 8)
5) !(7 > 6 || 3 > 4)
And it gives these answers to check your work: 1)
(true && true) || false == true || false == true
!(7 > 6 || 3 > 4) == !(true || false) == !true == false
Please explain how they got these answers, and why do the answers seem like they are too long? Please help me out, Im just learning this on my own so I have no teacher or anyone to ask. Thanks!
Hmmm, the concept for these operators seemed extremely simple until I got to these problems. Take number 4 for example. I understand 5 IS NOT greater than 6 so its false, 4 IS greater than 3 so it's true and 7 IS NOT greater so its false so of the answer I understand (false || true) && false this much, but what does this part == true && false == false mean?? Heres a link to the exact page so you can look over and see how it's written: http://www.learncpp.com/cpp-tutorial/36-logical-operators/
By the way is my question making sense? Hope so, everything else I've learned I understand but Ive been struggling with this part for a couple hours and cant make sense of it.