title: Measuring elapsed time in linux for a c program
body: <p>I am trying to measure elapsed time in Linux. My answer keeps returning zero which makes no sense to me. Below is the way i measure time in my program.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  #include &lt;time.h&gt;
  
  main()
  {
      double p16 = 1, pi = 0, precision = 1000;
      int k;
      unsigned long micros = 0;
      float millis = 0.0;
      clock_t start, end;
      start = clock();
      // This section calculates pi
      for(k = 0; k &lt;= precision; k++)
      {
          pi += 1.0 / p16 * (4.0 / (8 * k + 1) - 2.0 / (8 * k + 4) - 1.0 / (8 * k + 5) - 1.0 / (8 * k + 6));
          p16 *= 16;
      }
      end = clock();
      micros = end - start;
      millis = micros / 1000;
      printf("%f\n", millis); //my time keeps being returned as 0
  
      printf("this value of pi is  : %f\n", pi);
  }
  </code></pre>