sry sry o/p ll be 0 1 0....in the 2nd printf the value ll be evaluated from rite to left... so in the 1st printf i's vlue ll be 0 and in the 2nd printf stmt rite expression is evaluated first and then i value ll be modified in it.. and with hte help of it left one is evaluated...crct me if i'm wrong......
On 7/26/11, kavitha nk <kavithan...@gmail.com> wrote: > ans ll nt be 0 0 2 va??? > > On 7/25/11, Puneet Gautam <puneet.nsi...@gmail.com> wrote: >> @aditi: the "%2" in each of these printf statements is redundant coz >> it is "1%2"...and "%" has higher precedence over left or right >> shifts..thats y output of say : >> >> #include<stdio.h> >> main() >> { >> int i=1; >> printf("\n%d%d ",i<<=2,i<<=1%2); >> return 0; >> } >> >> is 8 8 >> >> 1 gets left shifted twice in i<<=2, becomes 4 >> then i<<1%2 concludes to i<<1 as 1%2 is 1 only.. >> i<<1 ,makes i=8 and hence >> >> 8 8 is printed..... >> >> On 7/25/11, Puneet Gautam <puneet.nsi...@gmail.com> wrote: >>> @rajeev: hey...does printf evaluate an expression right to left >>> without considering any priority of operators..? >>> Pls reply asap.. >>> >>> >>> >>> On 7/25/11, Puneet Gautam <puneet.nsi...@gmail.com> wrote: >>>> @aditi: y dont u try it out urself considering the priorities of >>>> different operators used here...!! >>>> that would help... >>>> >>>> On 7/25/11, aditi garg <aditi.garg.6...@gmail.com> wrote: >>>>> Can u plz elaborate...im not able to understand... >>>>> >>>>> On Mon, Jul 25, 2011 at 11:04 PM, rajeev bharshetty >>>>> <rajeevr...@gmail.com>wrote: >>>>> >>>>>> @sameer I think that is right >>>>>> >>>>>> >>>>>> On Mon, Jul 25, 2011 at 11:02 PM, sameer.mut...@gmail.com < >>>>>> sameer.mut...@gmail.com> wrote: >>>>>> >>>>>>> its because of side effect where value of i is getting changed twice >>>>>>> in >>>>>>> a >>>>>>> single line. >>>>>>> correct me if i am wrong :) >>>>>>> >>>>>>> *Muthuraj R. >>>>>>> 4TH Year BE.** >>>>>>> Information Science Dept* >>>>>>> *PESIT, Bengaluru . >>>>>>> * >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Mon, Jul 25, 2011 at 11:01 PM, geek forgeek >>>>>>> <geekhori...@gmail.com>wrote: >>>>>>> >>>>>>>> y not the output is 3 2 coz on right to left evaluation of printf >>>>>>>> i >>>>>>>> shud be left shifted by 1 bit wgich shud make it 2 ?? >>>>>>>> >>>>>>>> >>>>>>>> On Mon, Jul 25, 2011 at 10:28 AM, sameer.mut...@gmail.com < >>>>>>>> sameer.mut...@gmail.com> wrote: >>>>>>>> >>>>>>>>> yeah output >>>>>>>>> 0 >>>>>>>>> 1 1 >>>>>>>>> *is dis because of side effect? * >>>>>>>>> * * >>>>>>>>> * >>>>>>>>> * >>>>>>>>> *Muthuraj R. >>>>>>>>> 4TH Year BE.** >>>>>>>>> Information Science Dept* >>>>>>>>> *PESIT, Bengaluru . >>>>>>>>> * >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Mon, Jul 25, 2011 at 10:49 PM, Deoki Nandan >>>>>>>>> <deok...@gmail.com>wrote: >>>>>>>>> >>>>>>>>>> run on gcc compiler it would be >>>>>>>>>> 0 >>>>>>>>>> 1 1 >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Mon, Jul 25, 2011 at 10:35 PM, geek forgeek >>>>>>>>>> <geekhori...@gmail.com>wrote: >>>>>>>>>> >>>>>>>>>>> 1. >>>>>>>>>>> #include<stdio.h> >>>>>>>>>>> main() >>>>>>>>>>> { >>>>>>>>>>> int i=1; >>>>>>>>>>> printf("\n%d",i^=1%2); >>>>>>>>>>> printf("\n%d %d",i^=1%2,i<<=1%2); >>>>>>>>>>> return 0; >>>>>>>>>>> } >>>>>>>>>>> >>>>>>>>>>> output 3 3 >>>>>>>>>>> hey shudnt the output be 3 2 >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> 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. >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> **With Regards >>>>>>>>>> Deoki Nandan Vishwakarma >>>>>>>>>> >>>>>>>>>> * >>>>>>>>>> * >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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. >>>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> 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. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Regards >>>>>> Rajeev N B <http://www.opensourcemania.co.cc> >>>>>> >>>>>> >>>>>> -- >>>>>> 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. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Aditi Garg >>>>> Undergraduate Student >>>>> Electronics & Communication Divison >>>>> NETAJI SUBHAS INSTITUTE OF TECHNOLOGY >>>>> Sector 3, Dwarka >>>>> New Delhi >>>>> >>>>> 9718388816 >>>>> >>>>> -- >>>>> 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. >> >> > > > -- > //BE COOL// kavi > -- //BE COOL// kavi -- 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.