title: selection and iteration
body: <p>I am trying to write a c++ program where you can choose which operation you want to make and then choose the quantity of numbers to calculate the result. And I want to use a <code>getchar</code> function, but I cannot figure it out.
  How do you even make int so that it behaves like a variable?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  
  using namespace std;
  
  int main()
  {
  /*char a_char;
  a_char=getchar();
  cout&lt;&lt;a_char;*/
  
    int opcode;
    int a, b;
    int result;
  
    printf("Program for Addition, Subtraction, Multiplication and Division\n");
    printf("Enter Your Choice: 1 - Add, 2 - Sub, 3 - Mul, 4 - Div: ");
    scanf("%d", &amp;opcode);
    printf("Enter First Number:"); 
    scanf("%d", &amp;a);
    printf("Enter Second Number:");
    scanf("%d", &amp;b);
  
    switch(opcode)
    {
    case 1:
          result = a + b;
          printf("%d + %d = %d", a, b, result);
          break;
    case 2:
          result = a - b;
          printf("%d - %d = %d", a, b, result);
          break;
    case 3:
          result = a * b;
          printf("%d * %d = %d", a, b, result);
          break;
    case 4:
          result = a / b;
          printf("%d / %d = %d\n%d %% %d = %d", a, b, result, a, b, a % b);
          break;
    }
  
  }
  </code></pre>