+ 1
How can we use the break statement to end loops in c++?
4 Answers
+ 4
Whenever you call "break;" inside of a loop stops it, if instead you call "continue;" it directly goes to the next iteration.
What @James Jones meant was he creates an integer let's say "int stop = 0;"
Then inside of the loop "while(!stop)" you just need to set stop to anything else than 0 to end the loop.
However, unlike the break statement it will still execute the rest of the while content before stopping.
+ 2
well typically what I do is make the loop a while loop so you can create an interger to end the loop
+ 2
k. Thanks, James & QuentinJanuel
+ 1
pls explain further.