title: 20 Questions Game - Switch Statement
body: <p>I have been given the task of creating a 20 Questions game, using C++, where the user thinks of a number between 1 and 100 then the computer will guess it. In order to do this I have been trying to learn how to use the switch statement as I feel this will help me in my main code. However, I cannot seem to get it to work down to the constant error of an illegal break in the code. I have tried changing the code and looking online for answers however I have not been able to find any. My code is as follows:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
      {
      int i;
      cout &lt;&lt; "Enter an integer: ";
      cin &gt;&gt; i;
      switch (int i)
      {
          case i &gt; 1 :
          {
              cout &lt;&lt; "int greater than 1, less than 5"; endl;
              break;
          }
          case i &gt; 5 :
          {
              cout &lt;&lt; "int greater than 5 less than 10"; endl;
              break; 
          }
          case i &gt; 10 :
          {
              cout &lt;&lt; "int greater than 10"; endl;
              break; 
          }
      }
      system("PAUSE");
          return 0;
  
  }
  </code></pre>
  
  <p>And the error that shows is:</p>
  
  <pre><code>error C2043: illegal break  
  </code></pre>
  
  <p>If anyone could help me to answer why these errors keep on showing it would be very much appreciated!</p>