@dave,vaibhav and sandeep
thanks a lot... completely missed that part :D
On Wed, Jul 13, 2011 at 10:29 PM, Dave wrote:
> Because of short-circuit evaluation of boolean operators. As soon as
> the expression is known to be true, no further evaluation is needed.
> In this case ++i is true, and the
Because of short-circuit evaluation of boolean operators. As soon as
the expression is known to be true, no further evaluation is needed.
In this case ++i is true, and the result of true || anything is true.
Thus "anything" need not be evaluated, and is not in C. Similarly,
short-circuit evaluation
Because ++i returns non -ve i.e. true,
and since || operator exhibits short circuit. There was no need to evaluate
j++ && k++
Regards,
Sandeep Jain
On Wed, Jul 13, 2011 at 10:21 PM, shady wrote:
> && has higher precedence than ||
>
> but why does j and k didn't increase after the statement
@shady : lazy evaluation if first condition in OR is true... second
condition wont be evaluated
On Wed, Jul 13, 2011 at 10:21 PM, shady wrote:
> && has higher precedence than ||
>
> but why does j and k didn't increase after the statement
> l= ++i || j++ && k++;
> got executed ?
>
> On Wed
&& has higher precedence than ||
but why does j and k didn't increase after the statement
l= ++i || j++ && k++;
got executed ?
On Wed, Jul 13, 2011 at 10:07 PM, sagar pareek wrote:
> For more clarificationtry this :-
>
> int i=1,j=1,k=1,l;
> l= ++i || j++ && k++;
> printf("%d %d %d %d",i,j,k
For more clarificationtry this :-
int i=1,j=1,k=1,l;
l= ++i || j++ && k++;
printf("%d %d %d %d",i,j,k,l);
o/p will be 2 1 1 1
because as vaibhav wrote the equation evaluate as l= ++i || (j++ && k++);
only ++i evaluate not other two increments :)
On Sun, Jul 10, 2011 at 11:31 PM, rShetty wro
Got it Thanks .
On Jul 10, 10:40 pm, vaibhav shukla wrote:
> associativity comes into play when operators are of same precedence.
>
> On Sun, Jul 10, 2011 at 11:08 PM, vaibhav shukla
> wrote:
>
>
>
>
>
>
>
>
>
> > && has higher precedence than ||
> > the expression is evaluated as
> > z=j |