Need some explaining please

Can anyone explain to me how I should solve this in a correct order:

!( ( 1 || 0 ) && 0 )


I know the answer is 1, but can someone explain how to solve this in the right order
It's call operator precedence. In C++, the rules to solve are defined, just as they are defined in mathematics.
Last edited on
so how do I solve this?
First take expression in innermost parentes:
1.
1 || 0
operator || returns true if either one of two is true, otherwise false, so result is true (1)
2.
second parentes
1 && 0
operator && returns true if both true, otherwise false, so result is false (0)
3.
!0
operator ! is reversing (true is false, false is true), so result is true (1)
Last edited on
Thanks very much! :)
Topic archived. No new replies allowed.