title: Two decimal places using printf( )
body: <p>I'm trying to write a number to two decimal places using <code>printf()</code> as follows:</p>
  
  <pre><code>#include &lt;cstdio&gt;
  int main()
  {
    printf("When this number: %d is assigned to 2 dp, it will be: 2%f ", 94.9456, 94.9456);
    return 0;
  }
  </code></pre>
  
  <p>When I run the program, I get the following output:</p>
  
  <pre class="lang-none prettyprint-override"><code># ./printf
  When this number: -1243822529 is assigned to 2 db, it will be: 2-0.000000
  </code></pre>
  
  <p>Why is that?</p>
  
  <p>Thanks.</p>