Deliberately falls through the case : Switch « Language « C++






Deliberately falls through the case

Deliberately falls through the case

#include <iostream>
using namespace std;
int main(void)
{
   char choice;
   cout << "Choose your car\n";
   cout << "S \n";
   cout << "L \n";
   cout << "D \n";
   cin >> choice;
   cout << "Extra features purchased\n";
   switch (choice)
   {
       case 'D':
          cout << "D\n";
       case 'L':
          cout << "L\n";
          break;
       default: 
          cout << "None\n";
   }
   return 0;
}

           
       








Related examples in the same category

1.A switch statement in actionA switch statement in action
2.Switch: falling-through behaviorSwitch: falling-through behavior