the code is:
i = 2; j = 1
printf("%d", !!i + !j);
(the answer comes out to be 1... i don't understand why [and i don't know what the "!!" means (only the "!")...
the code is:
i = 2; j = 1
printf("%d", !!i + !j);
(the answer comes out to be 1... i don't understand why [and i don't know what the "!!" means (only the "!")...
What your code is saying is not(not)i + not j, which means i is a true statement, regardless of the integer you assigned and j is a false statement. So, in effect, your code is saying true + false. That will equal 1. If you change it to !i + !j, it will equal 0.
!! means not not.
x = 1;
if( x ) //true
if( !x ) //false
if( !!x ) //true
Recall that any non-zero value equates to true in a true/false test. Thus, not one means zero (or false), so not zero means true.
Quzah.
Hope is the first step on the road to disappointment.
Hmmm...two negatives equal a positive thing right...algebra strikes back. Then again it could mean other things but I dont' know how big Simpsons fans you people are so nevermind
-Microsofts Visual C++ Introductory Kit-
Current Projects: Learning Everything C.
Everyone has a photographic memory, some people just don't have any film.
______________________________
When was the last time you went for a colon cleansing? Because quite frankly, you're so backed up with crap that it's spilling out your mouth