title: C Programming - Anomaly behaviour of while loop for float condition
body: <p>I wrote the following code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main ()
  {
    float x = 1.1;
    printf("%s\n", "Hello!");
    while (x == 1.1)
    {
      printf("%s\n", "Hey there!");
      printf("%f\n", x);
      x = x - 0.1;
    }
    printf("%s\n", "Bye!");
    return 0;
  }
  </code></pre>
  
  <p>However the output was (which I assume was not expected):</p>
  
  <pre><code>aps120797@XENON-PC:/mnt/d/Codes/LetUsC$ gcc C04Ag.c
  aps120797@XENON-PC:/mnt/d/Codes/LetUsC$ ./a.out
  Hello!
  Bye!
  </code></pre>
  
  <p>To check if it accepts float condition or not, I wrote this code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main ()
  {
    float x = 1.1;
    printf("%s\n", "Hello!");
    while (x &gt;= 1.0)
    {
      printf("%s\n", "Hey there!");
      printf("%f\n", x);
      x = x - 0.1;
    }
    printf("%s\n", "Bye!");
    return 0;
  }
  </code></pre>
  
  <p>And I got the output as I expected.</p>
  
  <pre><code>aps120797@XENON-PC:/mnt/d/Codes/LetUsC$ gcc C04Ag.c
  aps120797@XENON-PC:/mnt/d/Codes/LetUsC$ ./a.out
  Hello!
  Hey there!
  1.100000
  Hey there!
  1.000000
  Bye!
  </code></pre>
  
  <p>So, my question is, <strong>what am I doing wrong in the first code</strong>? </p>
  
  <p><strong>UPDTATE</strong>: Just figured out how to correct this error.
  Appended the while condition like this: <code>while (x == 1.1f)</code></p>