Re: [algogeeks] Why this is giving run time error ?

2011-08-04 Thread Tushar Kanta Rath
@Dipankar : thanks.i think,this is the right logic

On Thu, Aug 4, 2011 at 11:10 AM, Dipankar Patro dip10c...@gmail.com 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 ij 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 tusharkanta.r...@gmail.com wrote:

 #includestdio.h
 main()
 {
  int j=4,i;
  goto L;
  for(i=0;ij;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 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.




 --

 ___

 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 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.




-- 
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 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.



Re: [algogeeks] Why this is giving run time error ?

2011-08-04 Thread Dipankar Patro
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 tusharkanta.r...@gmail.comwrote:

 @Dipankar : thanks.i think,this is the right logic

 On Thu, Aug 4, 2011 at 11:10 AM, Dipankar Patro dip10c...@gmail.comwrote:

 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 ij
 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 tusharkanta.r...@gmail.com wrote:

 #includestdio.h
 main()
 {
  int j=4,i;
  goto L;
  for(i=0;ij;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 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.




 --

 ___

 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 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.




 --
 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 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.




-- 
___

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 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.



[algogeeks] Why this is giving run time error ?

2011-08-03 Thread TUSHAR
#includestdio.h
main()
{
  int j=4,i;
  goto L;
  for(i=0;ij;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 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.