Can you use continue inside a switch inside a for loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can you use continue inside a switch inside a for loop?

Using continues inside switch/case statements are forbidden... even so i was wondering if its possible to use it in a switch inside a for/while loop

28th Dec 2018, 3:41 AM
Lucio Magno
Lucio Magno - avatar
1 Answer
+ 6
I might be breaking the rule here, but this C++ code runs just fine. #include <iostream> int main() { int arr[] {1,2,3,4,5}; for(int i {0}; i < 5; i++) { switch(arr[i]) { case 1: case 3: case 5: std::cout << arr[i] << "\n"; break; default: continue; } } return 0; } P.S. Include the intended language in Relevant Tags to narrow down question scope. (Edit) Languages included Hth, cmiiw
28th Dec 2018, 4:00 AM
Ipang