You can start by putting a breakpoint at each do/while/for and run the program using the debugger. The execution will halt at the break point. All you need do is count the expected number of breaks and then remove the breakpoint. When all breakpoints have been removed you should be in good shape for loop control.
BTW: If you are using oddball stuff like goto then this is a much harder problem to deal with.
Runtime: If your application never finishes a task, there is an infinite loop.
Code: Look for a loop whose stopping condition isn't set. This could be because you aren't properly incrementing or decrementing a counter/index variable or you aren't setting something to true/false because a condition is never met.
If loop termination is determined in part by user input then validate the user input before entering the loop. (Actually, you should always validate user input.)
Don't modify the loop variable within the body of the loop. For example, don't alter i within the body of the following loop.
Comment