title: How can I limit the number of digits displayed by printf after the decimal point?
body: <p>I wrote a small program that reads two integers using <code>scanf</code> and then performs various arithmetic calculations. I'm using <code>printf</code> to display the results. How can I make <code>printf</code> display only two digits after the decimal point? Starting with the simplified code sample:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
      double third = 1.0 / 3.0;
  
      // display data  
      printf("\n%20s%20s", "Description", "Data");
      printf("\n%20s%20s", "-----------", "----");
      printf("\n%20s%20lf", "One third", third);
      printf("\n");
      return 0;
  }
  </code></pre>
  
  <p>This prints "0.333333" for the value of <code>third</code>. How would I alter the above to get the following output?</p>
  
  <blockquote><pre>
           Description                Data
           -----------                ----
             One third                0.33
  </pre></blockquote>