title: Formatting numbers to n decimal places without rounding
body: <p>I want to create a c++ program to calculate the average of 3 positive numbers</p>
  
  <p>where (x,y,z)>0 and (x,y,z)&lt;=10</p>
  
  <p>I have this code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdio&gt;
  #include &lt;math.h&gt;
  
  using namespace std;
  
  int main()
  {
      int x,y,z;
      cin &gt;&gt; x &gt;&gt; y &gt;&gt; z;
      double x1,y1,z1,ma;
      x1 = x;
      y1 = y;
      z1 = z;
  
      if(x&gt;0 &amp;&amp; x&lt;=10 &amp;&amp; y&gt;0 &amp;&amp; y&lt;=10 &amp;&amp; z&gt;0 &amp;&amp; z&lt;=10)
          ma = (x1+y1+z1)/3;
      else
          return 0;
  
      printf("%.2f" , ma);
  
      return 0;
  }
  </code></pre>
  
  <p>For x=9, y=9 and z=5 the average is 23/3=7.666666666666667 and when I format to 2 decimal places, the result will be 7.67, but I want to appear 7.66 not 7.67.</p>
  
  <p>Please, can someone help me?</p>
  
  <p>Thank you!</p>