the expression involving and and or operator is evaluated from left to right
uptill the point from where the value of the expression can be determined.

On Mon, Jun 13, 2011 at 6:17 PM, Shachindra A C <sachindr...@gmail.com>wrote:

> || and && operators are called short circuit operators and need not
> necessarily evaluate the entire expression. In ex 1, m= ++i && ++j || ++k;
> here, ++i and ++j are done. then the result is orred with ++k; here,
> irrespective of the value of the right side(++k), the result would always be
> 1. Hence, the results.
>
>
> On Mon, Jun 13, 2011 at 6:12 PM, sahil <sahil18...@gmail.com> wrote:
>
>> can sme body tell me......?
>>
>> 1)
>> #include <stdio.h>
>> int main()
>> {
>>  int i= -3, j=2 ,k=0, m;
>> m= ++i && ++j || ++k;
>> printf("%d %d %d %d\n",i,j,k,m);
>> return 0;
>>
>>  }
>>  output:
>> -2 3 0 1
>>
>> 2)#include <stdio.h>
>> int main()
>> {
>>  int i= -3, j=2 ,k=0, m;
>> m= ++i || ++j && ++k;
>> printf("%d %d %d %d\n",i,j,k,m);
>> return 0;
>>
>>  }
>>
>> output:
>> -2 2 0 1
>>
>>
>> 3)
>> #include <stdio.h>
>> int main()
>> {
>>  int i= -3, j=2 ,k=0, m;
>> m= ++i && ++j && ++k;
>> printf("%d %d %d %d\n",i,j,k,m);
>> return 0;
>>
>>  }
>>
>> output:
>> -2 3 1 1
>>
>>
>>
>>  how came this output.........???????????
>> in the first code why..k is not incremented.....??
>> and hw the value of m came out to be 1...?
>>
>>
>> --
>> 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.
>>
>>
>
>
> --
> Regards,
> Shachindra A C
>
>  --
> 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.
>

-- 
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