title: C++ switch statement ending the menu
body: <p>Hey I am working on a Switch selection menu for my C++ programming class.  I have managed to get my menu to work, but I don't know how to stop the program on the exit selection in the menu I have made.</p>
  
  <p>My code is</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      char selection;
  
      do
      {
          cout &lt;&lt; "  IHCC Computer Science Registration Menu\n";
          cout &lt;&lt; "  ====================================\n";
          cout &lt;&lt; "  1.  Welcome to Computer Programming In C++\n";
          cout &lt;&lt; "  2.  Welcome to Java Programming\n";
          cout &lt;&lt; "  3.  Welcome to Android Programming\n";
          cout &lt;&lt; "  4.  Welcome to iOS Programming\n";
          cout &lt;&lt; "\n";
          cout &lt;&lt; "  5.  Exit\n";
          cout &lt;&lt; "  ====================================\n";
          cout &lt;&lt; "  Enter your selection: ";
          cin &gt;&gt; selection;
          cout &lt;&lt; endl;
  
          switch (selection)
          {
              case '1':
                  cout &lt;&lt; "Computer Programming In C++\n";
                  cout &lt;&lt; "\n";
                  break;
  
              case '2':
                  cout &lt;&lt; "Java Programming\n";
                  cout &lt;&lt; "\n";
                  break;
              case '3':
                  cout &lt;&lt; "Android Programming\n" ;
                  cout &lt;&lt; "\n";
                  break;
  
              case '4':
                  cout &lt;&lt; "iOS Programming\n";
                  cout &lt;&lt; "\n";
                  break;
  
              case '5':
                  cout &lt;&lt; "Goodbye.\n";
                  break;
  
              default: cout &lt;&lt;selection &lt;&lt; "is not a valid menu item.\n";
  
                  cout &lt;&lt; endl;
          }
  
      }while (selection != 0 );
  
      return 0;
  }
  </code></pre>