Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is the continue statement ignored in the switch statement?


Asked by Tobias Beil on Dec 12, 2021 FAQ



Yes, continue will be ignored by the switch statement and will go to the condition of the loop to be tested. I'd like to share this extract from The C Programming Language reference by Ritchie: The continue statement is related to break, but less often used; it causes the next iteration of the enclosing for, while, or do loop to begin.
Just so,
Switch is not considered as loop so you cannot use Continue inside a case statement in switch... The switch statement is inside a while loop, so continue is perfectly valid. – Rick Jul 26 '17 at 19:41
Thereof, Of course, you can't use a break to break out of a loop from inside a switch. Yes, continue will be ignored by the switch statement and will go to the condition of the loop to be tested. I'd like to share this extract from The C Programming Language reference by Ritchie:
Besides,
The continue statement is related to break, but less often used; it causes the next iteration of the enclosing for, while, or do loop to begin. In the while and do, this means that the test part is executed immediately; in the for, control passes to the increment step.
Likewise,
For the for loop, continue statement causes the conditional test and increment portions of the loop to execute. For the while and do...while loops, continue statement causes the program control to pass to the conditional tests.