title: Crazy Calculator
body: <p>The following is an edited code snippet from one of my larger programs. 
  <br><sup>(<a href="https://gist.github.com/NickKartha/6387434#file-maththingy-cpp-L24" rel="nofollow">Original code can be found here</a>)</sup></p>
  
  <p>I've made into a run-able program (It has errors)</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;math.h&gt;
  using namespace std;
  int main(){
      char op;
      double n1,n2;
      while(true){
          cin&gt;&gt; n1 &gt;&gt; op &gt;&gt; n2;
          switch(op){
              case '+' : cout&lt;&lt;n1 + n2 ; break;
              case '-' : cout&lt;&lt; n1 - n2 ; break;
              case 'x' :
              case '*' : cout&lt;&lt; n1 * n2 ; break;
              case '/' : cout&lt;&lt; n1/n2 ; break;
              case '^' : cout&lt;&lt; pow(n1,n2); break;
              case '&lt;' : (n1&lt;n2)? cout&lt;&lt;"True":cout&lt;&lt;"False"; break;
              case '&gt;' : (n1&gt;n2)? cout&lt;&lt;"True":cout&lt;&lt;"False"; break;
              case '=' : (n1==n2)? cout&lt;&lt;"True":cout&lt;&lt;"False"; break;
              case '%': int N1 = floor(n1); int N2 = floor(n2); cout &lt;&lt; N1 % N2; break;
              default : cout&lt;&lt; "That operation is not available";
          }
      }
  }
  </code></pre>
  
  <p><sub>Note : I am using Code::Blocks running on Windows Vista.</sub></p>
  
  <p>There are two issues that I am encountering with the code.</p>
  
  <ul>
  <li><p>I am unable to put the % part as a case in the switch-case. My compiler is throwing an error when I do this. The errors are:<br>
  <code>|line 20| jump to case label [-fpermissive]</code><br>
  <code>|line 19| crosses initialization of 'int N2'</code><br>
  <code>|line 19| crosses initialization of 'int N1'</code><br></p></li>
  <li><p>When I enter a gibberish value (string) for the input, the program goes into an infinite loop.</p></li>
  </ul>
  
  <p>Why are these things happening?</p>