C++ Programming Code Examples C++ > If Else and Switch Case Code Examples Switch Statement - what time is it Switch Statement - what time is it The if/else statement provides only two variants of actions. But often there are situations that we have to make decisions not only on true/false statements. For this purpose we can use switch statement: switch (expression) { case constant1: group-of-statements-1; break; case constant2: group-of-statements-2; break; . . . default: default-group-of-statements } for (int hour = 0; hour < 13; ++hour) { switch (hour) { case 2: cout << " It is 2 o'clock" << endl; break; case 5: cout << " It is 5 o'clock" << endl; break; default: cout << " I do not know" << endl; break; } }