title: Error: break statement not within loop, when in fact it is?
body: <p>G++ compiler gives the following error:</p>
  
  <p><code>error: break statement not within loop or switch</code></p>
  
  <p>While my code is as follows:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int number;
  
  int main() {
      cout &lt;&lt; "Let's check whether an integer is even or odd." &lt;&lt; endl;
      cout &lt;&lt; "Input new for checking a new number." &lt;&lt; endl;
      cout &lt;&lt; "Input 0 when done." &lt;&lt; endl;
  
      cout &lt;&lt; "Enter a number to check whether it's even or odd." &lt;&lt; endl &lt;&lt; endl;
      cin &gt;&gt; number;
      if (number == 0) {
          cout &lt;&lt; "Aborted." &lt;&lt; endl;
          break;
      } else if (number % 2 == 0) {
          cout &lt;&lt; "Number is even." &lt;&lt; endl;
      } else {
          cout &lt;&lt; "Number is odd." &lt;&lt; endl;
      }
  
      return (0);
  }
  </code></pre>
  
  <p>As you can see, the <code>break</code> statement <strong>is</strong> within a loop, an <code>if</code> loop, to be precise. So why is it giving this error?</p>