Facebook Pixel

How do I stop an infinite loop?

In the terminal, you can usually stop it by pressing Ctrl+C. In an IDE, use the Stop execution button.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Infinite Loops: What They Are and How to Avoid Them

An infinite loop is a sequence of instructions that continues to execute endlessly because its terminating condition is never met.

A TLE error almost always means your code entered an infinite loop, or your algorithm is too slow (e.g., O(n^2) when O(n) is expected).

Yes, if you write 'for(;;)' or if you tamper with the counter variable inside the loop in a way that prevents it from reaching the limit.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.