i tried in gcc of Ubuntu and its working fine....its not goin infinite ... On Thu, Jul 21, 2011 at 6:44 AM, Aman Goyal <aman.goya...@gmail.com> wrote:
> I think it is kind of illegal to use it, cos i tried this code on gcc > compiler oof ubuntu(code b) and the result is infinite loop, which doesnt go > with our logic at all. > > > On Thu, Jul 21, 2011 at 5:45 PM, karthiga m <karthichandr...@gmail.com>wrote: > >> no it is legal only... its working .... >> >> On 7/21/11, Reynald Suz <reynaldsus...@gmail.com> wrote: >> > I tried in Dev C++,code-B executes infinitely. Why? >> > >> > On Thu, Jul 21, 2011 at 4:13 PM, Gaurav Popli <abeygau...@gmail.com> >> wrote: >> > >> >> dont you think it is illegal using x=x-- or x=--x;?? >> >> >> >> On Thu, Jul 21, 2011 at 2:56 PM, karthiga m <karthichandr...@gmail.com >> > >> >> wrote: >> >> > in code A using pr e- decrement therefore i gets decremented when >> >> > checking while condition so >> >> > it will print as 9 8 7 6 5 4 3 2 1 ..... >> >> > in code B using post-decrement it will prints like 9 8 7 6 5 4 3 2 1 >> 0 >> >> > here why zero printing means while checking while condition x-- have >> >> > previous value..therefore at tht time x-- is 1 so while condition >> >> > executing and prints x value as zero. >> >> > >> >> > On 7/21/11, Reynald <reynaldsus...@gmail.com> wrote: >> >> >> Code: A >> >> >> int main() >> >> >> { >> >> >> int x = 10; >> >> >> while ( x = --x) >> >> >> printf( " %d ", x); >> >> >> getchar(); >> >> >> } >> >> >> >> >> >> Code: B >> >> >> int main() >> >> >> { >> >> >> int x = 10; >> >> >> while ( x = x--) >> >> >> printf( " %d ", x); >> >> >> getchar(); >> >> >> } >> >> >> >> >> >> Does Code-A and Code-B work similar? Justify. >> >> >> >> >> >> -- >> >> >> 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 >> > Reynald Reni >> > Masters in Software Engineering >> > CIT - India >> > >> > -- >> > 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.