!( ( 1 || 0 ) && 0 )
!( ( 1 || 0 ) && 0 )
Treat 1 as true and 0 as false, then evaluate the boolean expression.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
yeh thats what i need help with lol. im doing the tutorial on c++ i got the other two down but this last one is tricking me.
Do what with it?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
!( ( that part what do i do with the !
The ! symbol means logical not.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
yes i know that much but im stuck figuring it out...can you just show me how you would go about doing it?
Well, how would you evaluate (1 || 0)?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
as 1
So far so good. So how would you evaluate (1 && 0)?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
as 0.
Excellent. Just evaluate !0 and your problem is solved.
EDIT:
Strictly speaking, the result of (1 || 0) is true, not 1, and the result of (true && 0) is false, not 0.
Last edited by laserlight; 01-19-2008 at 01:57 AM.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
See i just didnt know the order of it all. Thanks alot!
No problem. Actually, with all those parentheses to group subexpressions the order of evaluation is no different from the arithmetic you used since elementary/primary school.
More tricky would be:
... which evaluates to false instead.Code:!( 1 || 0 && 0 )
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)