title: Input with cin is not working in switch case
body: <p>I am creating a program which asks user for reply and how many time you want to print reply and display it. I have used a while loop and switch case in the program.
  But when I store input in variable <code>a</code> with help of <code>std::cin</code>, the same input is not received by switch case. Any help is appreciated.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int a;
  int input;
  int i=1;
  void display()
  {
      cout &lt;&lt; "Select a choice for reply" &lt;&lt; endl;
      cout &lt;&lt; "1.Thank You" &lt;&lt; endl;
      cout &lt;&lt; "2.Welcome" &lt;&lt; endl;
      cout &lt;&lt; "3.Okay" &lt;&lt; endl;
  }
  
  int main()
  {
      display();
      cout &lt;&lt; "Enter Choice" &lt;&lt; endl;
      cin &gt;&gt; a;
      input='a';
      switch (input)
      {
          case '1': {
              int x;
              cout &lt;&lt; "Enter no. of times  you want to print reply line" &lt;&lt; endl;
              cin &gt;&gt; x;
              while (i &lt;= x)
              {
                  cout &lt;&lt; "Thank you" &lt;&lt; endl;
              }
  
              break;
          }
          case '2': {
              int x;
              cout &lt;&lt; "Enter no. of times  you want to print line" &lt;&lt; endl;
              cin &gt;&gt; x;
              while (i &lt;= x)
              {
                  cout &lt;&lt; "Welcome" &lt;&lt; endl;
              }
  
              break;
          }
          case '3': {
              int x;
              cout &lt;&lt; "Enter no. of times  you want to print line" &lt;&lt; endl;
              cin &gt;&gt; x;
              while (i &lt;= x)
              {
                  cout &lt;&lt; "okay" &lt;&lt; endl;
              }
  
              break;
          }
          default: {
              cout &lt;&lt; "wrong choice" &lt;&lt; endl;
          }
  
          cout &lt;&lt; "Thank you for replying" &lt;&lt; endl;
      }
  
      return 0;
  }
  </code></pre>