The output for third only correct 1,2 and 4 are wrong i think
printf() is evaluated from right to left and the post inceremet operator increses after assigning the value hence third is correct..... also tested them using Dev C++ compiler its working as i said above On Aug 1, 5:20 pm, thanu moorthy <[email protected]> wrote: > Please help me... > > How can the following output be obtained : > > 1.main() > > { > > int i=1; > > printf("%d\t%d\t%d\t",i,i++,i); > > } > > output: 2 1 2 > > 2.main() > > { > > int i=1; > > printf("%d\t%d\t%d\t",i,++i,i); > > } > > output: 2 2 2 > > 3.main() > > { > > int i=1; > > printf("%d\t%d\t%d\t",i,i++,i++); > > } > > output: 3 2 1 > > 4.main() > > { > > int i=1; > > printf("%d\t%d\t%d\t",i,++i,++i); > > } > > output: 3 3 3 > > Regards > by THANU -- 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.
