+ 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
1 Réponse
+ 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