Switch/Case statements in C++
- by vgoklani
Regarding the switch/case statement in the C++ code below: "Case 1" is obviously false, so how/why does it enter the do-while loop?
#include <iostream>
using namespace std;
int main() {
int test = 4;
switch(test) {
case 1: do {
case 2: test++;
case 3: test++;
case 4: cout << "How did I get inside the do-while loop?" << endl; break;
case 5: test++;
} while(test > 0);
cout << test << endl;
}
}