title: How to print a float number without extra zero digits in C
body: <p>When I print a float number with &quot;%f&quot;, it prints a float with 6 digits, but I don't want to print extra zeros. I can to use for example &quot;%.3f&quot; to print just 3 digits, but I want to print a float with number of random digits ,and using &quot;%.{number}f&quot; is not my answer. for example in:</p>
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
      float a, b;
      printf(&quot;Please enter a number: &quot;);
      scanf(&quot;%f&quot;, &amp;a);
      printf(&quot;Please enter another number: &quot;);
      scanf(&quot;%f&quot;, &amp;b);
      printf(&quot;%f&quot;, a / b);
      return 0;
  }
  </code></pre>
  <p>a/b can have even decimal digits. Of course, my question also applies to double and long double too.</p>