int main() { while (error>0.001); { OldVelocity = NewVelocity; NewVelocity = ((Yhigh - Ylow)/DeltaX) + OldVelocity; error = (OldVelocity - NewVelocity)/NewVelocity; } return 0; }

The equations I'm solving cannot be solved analytically - only numerically. In order for this to be done, they are converging to some acceptable answer (based on error between adjacent results). Sometimes after I execute the program I see a mistake or realize that my answer will never converge. I have programmed before but I am new to C++. I know in MatLab if you are stuck in an infinite loop you can hit Ctrl+C and the computer will break out of it. Is there a command to do this in C++ so if for some reason my computer is stuck in an infinite loop I can break it out???

If not should I just put a counter in my loop, and if it excedes a certain number the loop is terminiated regardless of the convergence criterion?

Thanks.