title: Do Not Output Trailing Zeroes in C++
body: <p>If the result is an integer, <strong>do not</strong> output the decimal point.</p>
  
  <p>If the result is a floating point number, <strong>do not</strong> output any trailing zeroes.</p>
  
  <p>How to do it in <code>c</code> or<code>c++</code>:</p>
  
  <pre><code>double result;
  /*some operations on result */
  printf("%g", result);
  </code></pre>
  
  <p>Is the above approach correct?  I'm not getting the correct answer with in my situation.</p>