title: Can't get cout to display decimals c++
body: <p>i can't get <code>cout</code> to display decimals (using eclipse c++ and mingw)</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main() {
  
      int a = 55, b = 60, c = 70;
  
      double avgResult;
  
      avgResult = ((a + b + c) / 3);
  
      cout &lt;&lt; avgResult;  //should display 61.666666
  
      return 0;
  }
  </code></pre>
  
  <p>my output is 61 when I would expect it to be 61.666666.</p>
  
  <p>I can get it to display the decimals using</p>
  
  <p><code>cout &lt;&lt; std::fixed &lt;&lt; std::setprecision(2) &lt;&lt; avrResult;</code></p>
  
  <p>but I thought I didn't need to do that unless I wanted a specific decimal precision.</p>
  
  <p>If I do something like</p>
  
  <pre><code>double value = 12.345;
  cout &lt;&lt; value;
  </code></pre>
  
  <p>it displays correctly so it leads me to believe that the above problem has to do with the use of <code>int</code> values in my calculation of <code>double avgResult</code></p>
  
  <p>btw I am new to c++ and am just starting to learn</p>