title: C++ Warning C4244 'return': conversion from 'double' to 'int', possible loss of data Visual Studio 2015
body: <p>New to C++, following a tutorial and trying to expand on it. My program compiles but I am getting the error "warning C4244: 'return': conversion from 'double' to 'int', possible loss of data" on line 23:
  <code>end: return(n1);</code> when compiling which means my calculator results are incorrect, ignoring decimal places and treating everything as an integer. I cannot find any instance in my code of an int apart from the 1 which I have specifically used. No doubles should be converting at all. Can anyone please have a look and let me know where I've gone wrong? I've attempted turning my current int into a double, and also using various other formatting styles to no avail.</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;cstdint&gt;
  
  using namespace std;
  
  int getNumber(int16_t x)
  {
      double n1{};
  
      if (x == 1)
      {
          cout &lt;&lt; "First number: ";
          cin &gt;&gt; n1;
          goto end;
      }
      else if (x == 2)
      {
          cout &lt;&lt; "Second number: ";
          cin &gt;&gt; n1;
          goto end;
      }
          end: return(n1);
  }
  
  int getOperator()
  {
      char op{};
      cout &lt;&lt; "Operator (+, -, *, /): ";
      cin &gt;&gt; op;
  
      return(op);
  }
  
  void printAnswer(double n1, char op, double n2)
  {
      if (op == '+')
          cout &lt;&lt; n1 &lt;&lt; " + " &lt;&lt; n2 &lt;&lt; " = " &lt;&lt; (n1 + n2) &lt;&lt; '\n';
      else if (op == '-')
          cout &lt;&lt; n1 &lt;&lt; " - " &lt;&lt; n2 &lt;&lt; " = " &lt;&lt; (n1 - n2) &lt;&lt; '\n';
      else if (op == '*')
          cout &lt;&lt; n1 &lt;&lt; " * " &lt;&lt; n2 &lt;&lt; " = " &lt;&lt; (n1 * n2) &lt;&lt; '\n';
      else if (op == '/')
          cout &lt;&lt; n1 &lt;&lt; " / " &lt;&lt; n2 &lt;&lt; " = " &lt;&lt; (n1 / n2) &lt;&lt; '\n';    
  }
  
  int main()
  {
      cout &lt;&lt; "Please enter two numbers and an operator to perform a calculation." &lt;&lt; endl;
  
      double n1(getNumber(1));
      char op(getOperator());
      double n2(getNumber(2));
  
      printAnswer(n1, op, n2);
  
      return(0);
  }
  </code></pre>