title: Iomanip setprecision() Method Isn't Working as It Should Only on the First Line, Why?
body: <p>So I'm writing a program to count the execution time of a function using clock and I used iomanip to change the output to decimal with 9 zeros.</p>
  <p>This is the code that I am using:</p>
  <pre><code>#include &lt;time.h&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  void linearFunction(int input)
  {
      for(int i = 0; i &lt; input; i++)
      {
  
      }
  }
  
  void execution_time(int input)
  {
      clock_t start_time, end_time;
  
      start_time = clock();
      linearFunction(input);
      end_time = clock();
  
      double time_taken = double(end_time - start_time) / double(CLOCKS_PER_SEC);
      cout &lt;&lt; &quot;Time taken by function for input = &quot; &lt;&lt; input &lt;&lt; &quot; is : &quot; &lt;&lt; fixed
           &lt;&lt; time_taken &lt;&lt; setprecision(9);
      cout &lt;&lt; &quot; sec &quot; &lt;&lt; endl;
  }
  
  int main()
  {
      execution_time(10000);
      execution_time(100000);
      execution_time(1000000);
      execution_time(10000000);
      execution_time(100000000);
      execution_time(1000000000);
  
      return 0;
  }
  </code></pre>
  <p>And the output shows:</p>
  <pre><code>Time taken by function for input = 10000 is : 0.000000 sec
  Time taken by function for input = 100000 is : 0.001000000 sec
  Time taken by function for input = 1000000 is : 0.002000000 sec
  Time taken by function for input = 10000000 is : 0.038000000 sec
  Time taken by function for input = 100000000 is : 0.316000000 sec
  Time taken by function for input = 1000000000 is : 3.288000000 sec
  </code></pre>
  <p>As you can see, the first time I call the function, it doesn't follow the setprecision(9) that I wrote. Why is this and how can I solve this? Thanks you in advance.</p>