title: Bubble sort floating point numbers in C
body: <p>I use bubble sort to <code>1.00 20.00 3.30 4.50 5.20 6.10 7.80 8.10 9.14 0.67</code> and i end up with</p>
  
  <p><code>0.00 1.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 20.00</code> </p>
  
  <p>This is my code</p>
  
  <pre><code>main()
  {
  int i,n = 10,j,value=0;
  float median=0;
  float a[10] = {1,20,3.3,4.5,5.2,6.1,7.8,8.1,9.14,0.67};
  for(i= 0; i&lt; 10; i++) {
      printf("%.2f  ", a[i]);
  }
  printf("\n\n");
  for(i=0;i&lt;n-1;i++)
  {
      for(j=0;j&lt;n-i-1;j++)
      {
          if(a[j]&gt;a[j+1])
          {
              value=a[j+1];
              a[j+1]=a[j];
              a[j]=value;
          }
      }
  }
  for(i= 0; i&lt; 10; i++) {
      printf("%.2f  ", a[i]);
  }
  }
  </code></pre>
  
  <p>Can anyone tell me what I am doing wrong and why I am losing all the digits after the decimal point when I am done with the sort.</p>
  
  <p>P.S. I am using an online compiler <a href="http://www.compileonline.com/compile_c_online.php" rel="nofollow">http://www.compileonline.com/compile_c_online.php</a> .</p>