@dave,vaibhav and sandeep
thanks a lot... completely missed that part :D

On Wed, Jul 13, 2011 at 10:29 PM, Dave <[email protected]> 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 result of true || anything is true.
> Thus "anything" need not be evaluated, and is not in C. Similarly,
> short-circuit evaluation occurs with &&: when the result is known to
> be false, no further evaluation is needed. Thus, false && anything
> will produce false without evaluating "anything".
>
> Dave
>
> On Jul 13, 11:51 am, shady <[email protected]> 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, Jul 13, 2011 at 10:07 PM, sagar pareek <[email protected]
> >wrote:
> >
> >
> >
> > > For more clarification....try 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 <[email protected]>
> wrote:
> >
> > >> Got it Thanks .....
> >
> > >> On Jul 10, 10:40 pm, vaibhav shukla <[email protected]> wrote:
> > >> > associativity comes into play when operators are of same precedence.
> >
> > >> > On Sun, Jul 10, 2011 at 11:08 PM, vaibhav shukla <
> > >> [email protected]>wrote:
> >
> > >> > > && has higher precedence than ||
> > >> > >  the expression is evaluated as
> > >> > > z=j || ( k && i );
> > >> > > hence the output i.e 1 ;)
> >
> > >> > > On Sun, Jul 10, 2011 at 11:06 PM, rShetty <[email protected]>
> > >> wrote:
> >
> > >> > >> #include<stdio.h>
> > >> > >> int main()
> > >> > >> {
> > >> > >>  int i=0,j=1,k=1,z=0;
> > >> > >>  z = j || k  && i ;
> > >> > >>  printf("%d",z);
> > >> > >>  return 0;
> > >> > >> }
> >
> > >> > >> The output is 1 for the above program .
> >
> > >> > >> But according to associativity of logical operators , the
> evaluation
> > >> > >> should be from left to right , But is it taking from right to
> left ?
> > >> > >> What is the exact concept for the program behavior above?
> >
> > >> > >> --
> > >> > >> You received this message because you are subscribed to the
> Google
> > >> Groups
> > >> > >> "Algorithm Geeks" group.
> > >> > >> To post to this group, send email to [email protected].
> > >> > >> To unsubscribe from this group, send email to
> > >> > >> [email protected].
> > >> > >> For more options, visit this group at
> > >> > >>http://groups.google.com/group/algogeeks?hl=en.
> >
> > >> > > --
> > >> > >   best wishes!!
> > >> > > Vaibhav Shukla
> > >> > >     DU-MCA
> >
> > >> > --
> > >> >   best wishes!!
> > >> > Vaibhav Shukla
> > >> >     DU-MCA
> >
> > >> --
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "Algorithm Geeks" group.
> > >> To post to this group, send email to [email protected].
> > >> To unsubscribe from this group, send email to
> > >> [email protected].
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/algogeeks?hl=en.
> >
> > > --
> > > **Regards
> > > SAGAR PAREEK
> > > COMPUTER SCIENCE AND ENGINEERING
> > > NIT ALLAHABAD
> >
> > >  --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to