title: Strange output when using float instead of double
body: <p>Strange output when I use <code>float</code> instead of <code>double</code></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  void main()
  {
      double p,p1,cost,cost1=30;
      for (p = 0.1; p &lt; 10;p=p+0.1)
      {
          cost = 30-6*p+p*p;
          if (cost&lt;cost1)
          {
              cost1=cost;
              p1=p;
          }
          else
          {
              break;
          }
          printf("%lf\t%lf\n",p,cost);
      }
      printf("%lf\t%lf\n",p1,cost1);
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/p5glS.png" alt="As Expected"></p>
  
  <p>Gives output as expected at <code>p</code> = 3;</p>
  
  <p>But when I use <code>float</code> the output is a little weird.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  void main()
  {
      float p,p1,cost,cost1=40;
      for (p = 0.1; p &lt; 10;p=p+0.1)
      {
          cost = 30-6*p+p*p;
          if (cost&lt;cost1)
          {
              cost1=cost;
              p1=p;
          }
          else
          {
              break;
          }
          printf("%f\t%f\n",p,cost);
      }
      printf("%f\t%f\n",p1,cost1);
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/C3vdU.png" alt="Strange increment style"></p>
  
  <p>Why is the increment of <code>p</code> in the second case going weird after 2.7?</p>