Nope ,the output is correct.as I had studied somewhere ,i don't remember
where exactly but
in (x||y) type condition's,if x evaluates to true( non zero) then value of
y doesn't matter and is not evaluated and condition turns out to be true
anyhow without even checking y ,control never goes to y and y is never
executed;
now in your case m=++i || ++j && ++k;
since precedence of && is more than or,so we can take it as m=++i || (++j
&& ++k);
now expression evaluates to true just by checking i++ which is -2 now(non
zero) and value of ++j && ++k is not even checked nor changed ,hence both j
and k remain unchanged.
This is a correct explanation u can rely an this.
thank you :)

On Tue, Jun 12, 2012 at 2:19 AM, Dave <dave_and_da...@juno.com> wrote:

> This is the result of short-circuit evaluation. See, e.g.,
> http://en.wikipedia.org/wiki/Short-circuit_evaluation, or this topic in
> your language reference.
>
> Dave
>
> On Monday, June 11, 2012 2:28:52 PM UTC-5, ((** VICKY **)) wrote:
>
>> #include<stdio.h>int main(){int i,j,k,m,l;
>> i=-3;
>> j=2;
>> k=0;m=++i || ++j && ++k ;printf 
>> <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("\n%d 
>> %d %d %d",i,j,k,m);return 0;}
>>
>> o/p: -2 2 0 1
>>
>>
>> k should be 1 right????
>>
>>
>> --
>> Cheers,
>>
>>   Vicky
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/8PoAya7NqjYJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to