# Thread: so confused - learning something

1. ## so confused - learning something

Im going through the C++ Tutorial and i am on page 2. Im having trouble understanding the following problem...

!( ( 1 || 0 ) && 0 ) (answer is 1 but how?)

what i see is...

not 1 or 0 and not 0
so i dont understand how they get one...explanation please?

2. Do brackets first:

= !( ( 1 || 0 ) && 0 )
//1 || 0 - is either 1, yes, the left is, so its true (1)

= !( 1 && 0 )
//1 && 0 - are both sides 1?, no, so its false (0)

= !(0)
//remove the backets to simplify

= !0
//what is the opposite of 0 (NOT 0), its 1.

= 1

3. = !( ( 1 || 0 ) && 0 )
//1 || 0 - is either 1, yes, the left is, so its true (1)

i dont get how 1 || 0 like you stated above is one..what i see is..not 1 or 0...so wouldnt it be 0?

4. Originally Posted by marky03
= !( ( 1 || 0 ) && 0 )
//1 || 0 - is either 1, yes, the left is, so its true (1)

i dont get how 1 || 0 like you stated above is one..what i see is..not 1 or 0...so wouldnt it be 0?
No no no.. its like math, you do whats in the brackets () first, before worrying about what it says outside them. You'll also notice its ! ( ( , theres 2 backets, so the ! NOT symbol has no effect ever on ( 1 || 0 ).

= !( ( 1 || 0 ) && 0 )
//1 || 0 - is either 1, yes, the left is, so its true (1)

do the contents of the bolded bracket first, then replace that part with the outcome, which is 1.

Leaving !( 1 && 0 ), do the contents of the brackets first, is it 1 && 1? no, then it must be false (which is 0), so replace the bracketted part with 0.

Leaving you with !0, NOT 0 is 1.

5. I now get it! Thank you!