title: Print a variable number of digits of a double using printf
body: <p>Anyone knows if it is possible to use printf to print a VARIABLE number of digits?</p>
  
  <p>The following line of code prints exactly 2:</p>
  
  <pre><code>printf("%.2lf", x);
  </code></pre>
  
  <p>but let's say I have a variable:</p>
  
  <pre><code>int precision = 2;
  </code></pre>
  
  <p>Is there a way to use it in printf to specify the number of digits?</p>
  
  <p>Otherwise I will have to write a 'switch' or 'if' structure.</p>
  
  <p>Thanks </p>