What is "break" used for in a loop? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 3

What is "break" used for in a loop?

What is "break" used for in a loop?

27th Jul 2017, 11:50 AM
MintyNerdyPoodle
MintyNerdyPoodle - avatar
4 Antworten
+ 3
I take it in c++, it means "stop the code here" you can use it with the loops or switch statement. So if you trying to print numbers from 1-100 you can tell the program to stop in 80 Example If (num == 80) Break;
27th Jul 2017, 12:03 PM
Raed S Matti
Raed S Matti - avatar
+ 3
Thanks, Raed Matti!
27th Jul 2017, 1:21 PM
MintyNerdyPoodle
MintyNerdyPoodle - avatar
0
You are welcome
27th Jul 2017, 1:48 PM
Raed S Matti
Raed S Matti - avatar
0
To terminate the loop
3rd Feb 2019, 12:37 AM
Rahul
Rahul - avatar