Question about Boolean

Hello,

I'm a beginner at C++, and I'm having trouble understanding Boolean:

1
2
3
  ( ! ( true || false) ) //This ends up false
  ( ! ( true || false && false) ) //This ends up false
  ( ! ( ( true || false ) && false ) // This ends up true. 


Now this confuses me. I understand the precedence of the operators, Boolean not being first, then Boolean and, and lastly Boolean or.

For example, the first one, ( ! ( true || false) ). Wouldn't that end up: ( ! ( !true || !false) ). So wouldn't the !false become true? This is where I'm confused.

Thanks in advance!
true||false will result true then its negated with ! so its false
what you ask is !(!true||!false) it'll become !(false||true) because both value is negated with !
Start with the innermost parenthesis.

(true || false) is true. Not true is false.

!(true || false) -> !true -> false
Figured it out! Thanks!
Last edited on
Topic archived. No new replies allowed.