If you have a switch statement and want certain code to be run when the value is one value or another how do you do it? The following code always goes to the defaul
Like this:
switch (x)
{
case 5:
case 2:
cout << "here I am" << endl;
break;
}
Known as "falling through".
Just to point out that the reason the default case is executed in the posted code is that the result of 5 || 2 is 1 (true). If you set x to 1 in the posted code the 5 || 2 case would be executed (see http://ideone.com/zOI8Z).