You are welcome Tushar. My suggestion is always to print the value of iter (i in this case) in a loop if you think there is something wrong. Helps 99% of times.
On 4 August 2011 20:13, Tushar Kanta Rath <[email protected]>wrote: > @Dipankar : thanks.............i think,this is the right logic > > On Thu, Aug 4, 2011 at 11:10 AM, Dipankar Patro <[email protected]>wrote: > >> Well I think the reason is very simple: >> When you enter the loop through L, the value of i is not initialized to 0, >> it is some garbage value. >> now while exiting the loop, the condition is checked for another >> iteration. Since the value of i is unknown, it might be the case that i<j >> for a lot of number of times before the loop actually ends. >> >> But it is not a runtime error, and no infinite loop. the loop will end, >> the moment value of i becomes >= j. >> >> On 4 August 2011 11:00, TUSHAR <[email protected]> wrote: >> >>> #include<stdio.h> >>> main() >>> { >>> int j=4,i; >>> goto L; >>> for(i=0;i<j;i++) >>> { >>> >>> L: >>> printf("%d",j); >>> } >>> } >>> >>> >>> >>> >>> why this is giving infinite loop.................Runtime error ? >>> >>> >>> >>> -- >>> 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. >>> >>> >> >> >> -- >> >> ___________________________________________________________________________________________________________ >> >> Please do not print this e-mail until urgent requirement. Go Green!! >> Save Papers <=> Save Trees >> >> -- >> 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. >> > > > > -- > Tushar Kanta Rath, > Master In Computer Application > MNNIT, 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. > -- ___________________________________________________________________________________________________________ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers <=> Save Trees -- 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.
