Mega Code Archive

 
Categories / C++ Tutorial / Operators Statements
 

Switch case falling through

#include <iostream> using namespace std;    int main()  {    int i;      for(i=0; i<5; i++) {     switch(i) {        case 1:        case 2:        case 3:           cout << "i is less than 4";          break;        case 4:           cout << "i is 4";          break;     }         cout << '\n';    }      return 0;  } i is less than 4 i is less than 4 i is 4