title: Why does this C++ program round double values and not print the whole string?
body: <p>I was working on a HackerRank problem and I could not figure out why the C++ code round the double values when I am adding them and why it does not take in/print the entire string input it is given.</p>
  
  <p>The code is supposed to take in an integer input (from one line), a double input (from another line), and a string input (also, from another line). Then it is supposed to print out the sum of the int input and 4, the sum of the double input and 4.0, and concatenate the string "HackerRank" to the beginning of the input string.</p>
  
  <p>Here's the code I have:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;limits&gt;
  
  int main(){
      int i = 4;
      double d = 4.0;
      string s = "HackerRank";
  // Declare second integer, double, and String variables.
  
  // Read and save an integer, double, and String to your variables.
  // Note: If you have trouble reading the entire string, please go back and review the Tutorial closely.
  
  // Print the sum of both integer variables on a new line.
  
  // Print the sum of the double variables on a new line.
  
  // Concatenate and print the String variables on a new line
  // The 's' variable above should be printed first.
  
      int a;
      double b;
      string c;
  
      cin &gt;&gt; a; 
      cin &gt;&gt; b;
      cin &gt;&gt; c;
  
  
      a = a + i;
      b = b + d;
  
      cout &lt;&lt; a &lt;&lt; endl;
      cout &lt;&lt; b &lt;&lt; endl;
      cout &lt;&lt; "" + s + c;
  
      return 0;
  }
  </code></pre>
  
  <p>For the following input:</p>
  
  <pre><code>12
  4.0
  is the best place to learn and practice coding!
  </code></pre>
  
  <p>I got the output:</p>
  
  <pre><code>16
  8
  HackerRank is
  </code></pre>
  
  <p>When this is the expected output:</p>
  
  <pre><code>16
  8.0
  HackerRank is the best place to learn and practice coding!
  </code></pre>