Re: [algogeeks] Re: Precedence of operators

2011-07-13 Thread shady
@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

[algogeeks] Re: Precedence of operators

2011-07-13 Thread Dave
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

Re: [algogeeks] Re: Precedence of operators

2011-07-13 Thread Sandeep Jain
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

Re: [algogeeks] Re: Precedence of operators

2011-07-13 Thread vaibhav shukla
@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

Re: [algogeeks] Re: Precedence of operators

2011-07-13 Thread shady
&& 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

Re: [algogeeks] Re: Precedence of operators

2011-07-13 Thread sagar pareek
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

[algogeeks] Re: Precedence of operators

2011-07-10 Thread rShetty
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 |