sry but i cant understand wht u r trying to say. i am asking dat i am using many while loops and for loops in my program however if due sum condition or anything else the loop enters in an infintite loop do i have any way to detect it so dat i can report it to the user that the program has entered in an infintite loop???
I don't think there is any easy way to catch this kind of thing. After all, a program often has to loop many times. At what point does "many" become "too many"? It would depend on the particular circumstances. In some cases, you may
want it to loop "forever".
I suppose you could increment a counter each time around a loop, and clear it after exiting the loop. Keep watching it, and if it gets too large (you'd need to decide just how much is too much) then do your thing.
Probably the simplest way to implement that would be by calling some kind of standard "count these calls and tell me if I've done more than
x" function.
By the way, as far as I can see what hariharanmca posted was not a way to detect an infinite loop, but an easy way to
create one. Although this would not in fact keep going forever, as it would produce something like a "stack overflow" error after a while.