float fl = 10.5;
double dbl = 10.5
printf("UNITED WE STAND");
printf("DIVIDE AND RULE")
it is a c program
I am getting answer UNITED WE STAND in the above program and if I change the values like fl=10.7 and dbl=10.7 I am getting answer DIVIDE AND RULE ,can anyone please explain me why are we getting different outputs
Not all floating-point numbers can be represented precisely by a computer. 10.7 is not a valid "exact" value for both float and double. It is represented by values very close to original but these values are not equal to 10.7. These representations differs slightly between float and double (float has less precision). So when you convert floating 10.7 value to double you get not a 10.7 double but something very close to it. However 10.5 can be represented precisely in floating-point type so values are equal even after float->double conversion.
You may read more about floating point numbers here.