title: Console calculator program in C++ not working correctly
body: <p>I'm kind of new to programming in C++, and after a bit of learning how it works, I tried making this console calculator application, which takes in two numbers from the user x and y, and then adds, subtracts, multiplies or divides the two numbers depending on the third z input. I'm using code blocks as the IDE, and the code is as follows:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  //First input value
  int x;
  //Second input value;
  int y;
  //Operator value;
  int z;
  int main()
  {
      //Asks user for first number
      std::cout &lt;&lt; "Input first number" &lt;&lt; std::endl;
      std::cin &gt;&gt; x;
      std::cout &lt;&lt; "" &lt;&lt; std::endl;
  
      //Asks user for second number
      std::cout &lt;&lt; "Input second number" &lt;&lt; std::endl;
      std::cin &gt;&gt; y;
      std::cout &lt;&lt; "" &lt;&lt; std::endl;
  
      //Asks user for operation
      std::cout &lt;&lt; "Input operation: 1 for add, 2 for sub, 3 for multiply, 4 for divide" &lt;&lt; std::endl;
      std::cin &gt;&gt; z;
  
      //Displaying the desired output
      if (z = 1)
      {
          std::cout &lt;&lt; x + y &lt;&lt; std::endl;
      }
      else if (z = 2)
      {
          std::cout &lt;&lt; x - y &lt;&lt; std::endl;
      }
      else if (z = 3)
      {
          std::cout &lt;&lt; x * y &lt;&lt; std::endl;
      }
      else (z = 4);
      {
          std::cout &lt;&lt; x / y &lt;&lt; std::endl;
      }
  
      //Just a stupid comment
      std::cout &lt;&lt; "Thank you for using this piece of shit xD. Press any key to end" &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>Even though it compiles without any errors, every operation input seems to add the numbers together rather than the desired operation. Could anyone tell me what I'm doing wrong here?</p>