We start with k = 5. if ++k < 5 translates to if 6 < 5 => which is false. No need to evaluate k++/5 (short-circuiting) if ++k <= 8 translates to (6+1) 7 <= 8 which is true. So, 7 gets printed.
On Tuesday, November 6, 2012 6:22:13 AM UTC-5, Anil Sharma wrote: > > main() > { > int k = 5; > if (++k < 5 && k++/5 || ++k <= 8); > printf("%d ", k); > } > > the output shud be 8 but it comes out to be 7.why??? > as increment operator has higher precedence among them so increment shud > be done throughout at first and after then other operators shud be > evaluated.so output shud be 8. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/KgsSjel6n_4J. 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.