How to terminate an infinite loop ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How to terminate an infinite loop ?

19th Jul 2019, 1:35 PM
HARSHADITYA SHARMA
HARSHADITYA SHARMA - avatar
15 Answers
+ 6
Use if conditional and break;
19th Jul 2019, 1:39 PM
Dwi Novianto Nugroho
Dwi Novianto Nugroho - avatar
+ 5
Use some conditional statement and break the loop using break;
20th Jul 2019, 5:20 AM
Manoj
Manoj - avatar
+ 2
you can also use return if you want to end the function also
19th Jul 2019, 3:53 PM
Bebida Roja
Bebida Roja - avatar
+ 2
Break is best
20th Jul 2019, 6:08 AM
Akash Kumar Singh
Akash Kumar Singh - avatar
+ 2
Ferran Esparza I think OP meant to stop it programatically.
20th Jul 2019, 2:51 PM
Bebida Roja
Bebida Roja - avatar
+ 2
Bebida Roja I think so. But I needed to say that option
20th Jul 2019, 2:53 PM
Ferran Esparza
Ferran Esparza - avatar
+ 2
Apply conditional statement for checking user input if input != some_value: break
22nd Jul 2019, 9:04 PM
Anil
+ 2
Using break and conditional statement 👍
23rd Jul 2019, 4:14 PM
Shubham Dwivedi
Shubham Dwivedi - avatar
+ 2
To terminate an infinite loop just use the Break function
27th Jul 2019, 12:47 AM
jack frost
jack frost - avatar
+ 1
Use if conditions
19th Jul 2019, 2:12 PM
Shankey Peter
+ 1
Ctrl +C
20th Jul 2019, 2:44 PM
Ferran Esparza
Ferran Esparza - avatar
+ 1
I wanted to know how to end an infinite loop on a particular user input. But thanks for all the varied answers
20th Jul 2019, 2:56 PM
HARSHADITYA SHARMA
HARSHADITYA SHARMA - avatar
+ 1
1. use conditional loops with break or 2. press the stop button when u run an infinite loop , hope it helps
21st Jul 2019, 4:31 AM
Simon Yu
0
Ferran Esparza You had the need lol
20th Jul 2019, 2:54 PM
Bebida Roja
Bebida Roja - avatar
0
Ask the user how many times should ut execute and then use if statement and break it
20th Jul 2019, 5:23 PM
Devank Sachdeva
Devank Sachdeva - avatar