floating point numbers are stored within the computer in binary floating point format to a certain number of significant figures, for example typical values for a 32 bit float variable is 6 significant decimal figures and 64 bit double is 15 significant decimal figures.
Hence 7.2 when in a binary format may be stored inside the computer as 7.199999
in the code
a is initialised to to float value 7.2 (to 6 significant figures)
however, in the comparision
7.2 is a double constant, a is converted to a double for the < comparision which causes the problem
consider
-
float a=7.2;
-
double b=7.2;
-
printf("%20.15lf\n" ,(double)a);
-
printf("%20.15lf\n", b);
-
prints
7.199999809265137
7.200000000000000
here we see that when a (float value 7.2) is converted to a double its value is less than b (double value 7.2) which is why you program says a is less than 7.2.
if you change the test to
you are comparing a float with a float