title: Not able to take the user input when using if-else and switch case [ C language]
body: <p>I want someone to run the code, you will find that the code at line number 14 to 17, I don't what this error is. I am giving my code along with this error image.</p>
  <p><a href="https://i.stack.imgur.com/qlzue.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qlzue.png" alt="enter image description here" /></a></p>
  <pre class="lang-c prettyprint-override"><code>/*
      A simple calculator made with if-else and switch case
  */
  
  #include &lt;stdio.h&gt;
  
  int main() {
      // if-else
      
      char _opt_1;
      float x_1, x_2;
      
      printf(&quot;Enter a valid operator from (+ , - , * , /:  &quot;);
      scanf(&quot;%c&quot;, &amp;_opt_1);
      
      printf(&quot;Enter first number: &quot;);
      scanf(&quot;%f&quot;, &amp;x_1);
      printf(&quot;Enter second number: &quot;);
      scanf(&quot;%f&quot;, &amp;x_2);
      
      if(_opt_1=='+') {
          printf(&quot;The sum is: %f \n&quot;, x_1+x_2);
      }else if(_opt_1=='-') {
          printf(&quot;The sum is: %f \n&quot;, x_1-x_2);
      }else if(_opt_1=='*') {
          printf(&quot;The sum is: %f \n&quot;, x_1*x_2);
      }else if(_opt_1=='/') {
          printf(&quot;The sum is: %f \n&quot;, x_1/x_2);
      }else{
          printf(&quot;Please enter a valid operator \n&quot;);
      }
      
      // switch case
      char operator;
      float x, y;
      
      printf(&quot;Enter the operation you want to perform like (+,-,*,/): &quot;);
      scanf(&quot;%c&quot;, &amp;operator);
      
      printf(&quot;Enter the first number: &quot;);
      scanf(&quot;%f&quot;, &amp;x);
      printf(&quot;Enter the second number: &quot;);
      scanf(&quot;%f&quot;, &amp;y);
      
      switch(operator) {
          case '+':
              printf(&quot;The sum is: %f&quot;, x + y);
              break;
          case '-':
              printf(&quot;The difference is: %f&quot;, x - y);
              break;
          case '*':
              printf(&quot;The product is: %f&quot;, x * y);
              break;
          case '/':
              printf(&quot;The division is: %f&quot;, x / y);
              break;
          
          default:
              printf(&quot;Please enter a valid operator&quot;);
      }
      
      return 0;
  }
  </code></pre>