title: How to set the output precision to 2 decimal places in C++?
body: <p>I want to globally set the ouptut precision to 2 decimal places.</p>
  
  <p>I already tried to use <code>iomanip</code> and <code>setprecision</code>, however I keep getting output with 'e' in it.</p>
  
  <p>This is my example code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  int main ()
  {
      double pay=16.78;
      double hours;
      double total;
  
      cout.precision(2); 
  
      cout &lt;&lt; "Please enter how many hours you worked : " &lt;&lt; endl;
      cin &gt;&gt; hours;
  
      total=hours*pay;
  
      cout &lt;&lt; "You earned: " &lt;&lt; total &lt;&lt; endl;
  }
  </code></pre>