title: How to detect if a number is a whole number or a float in C?
body: <p>So I am new to C, and I mainly use it to make calculators for probability and stuff like that. My current project finds the increase and decrease of 2 values.</p>
  <p>The code is:</p>
  <pre><code>
  #include &lt;stdio.h&gt;
  //Variables
  
  //Main Area
  int
  main ()
  {
    float num1;
    float num2;
    float num3;
    float num4;
    float answer;
    //Scanning for the first number
    printf (&quot;\n Please Enter the first Value : &quot;);
    scanf (&quot;%f&quot;, &amp;num1);
    //scanning for the second number
    printf (&quot;\n Please Enter the second Value : &quot;);
    scanf (&quot;%f&quot;, &amp;num2);
    //calculating
    num3 = num1 - num2;
    num4 = num3 / num1;
    answer = num4 * 100;
    //Checking if the answer is an increase or decrease
    if (answer &gt; 0) {
        printf(&quot;The answer has been decreasedby: %f\n&quot;, answer);
        printf(&quot;percent&quot;);
    }
    else {
      
        printf(&quot;The answer has been increased by: %f\n&quot;, answer * -1);
        printf(&quot;percent&quot;);
    }
    
    
    //Printing the answer
    
   
  }
  
  
  </code></pre>
  <p>The output:</p>
  <pre><code> Please Enter the first Value: 9                                                                                                                            
   Please Enter the second Value : 90                                                                                            
  The answer has been increased and the final value is: 900.000000                                                               
  percent
  </code></pre>
  <p>So I set all the values as <code>Floats</code> rather than <code>Ints</code> because <code>Ints</code> only support whole numbers. But when I do get a whole number rather then displaying only the single number with no decimal points, it produces a number with the number and a bunch of zeros after the decimal point. Is there a way to detect if the number Is a whole number and just display that number?</p>
  <p>Thanks</p>