Replacing the %f with %d
What happens if you replace the f with a d? Th output is a different number, but where does it come from? https://code.sololearn.com/cQNjXkk5TA4o/?ref=app
The output is due to undefined behaviour. The float is represented usually in IEEE754 binary format (sign, then exponent, and then mantissa) and maybe that was interpreted as an integer. Or something else happened. The reason for this is explained here: https://stackoverflow.com/questions/7480097/what-happens-to-a-float-variable-when-d-is-used-in-a-printf
Very interesting question! Great answer Kinshuk. 8) Also, my favorite Wiki page of all times is https://en.wikipedia.org/wiki/Undefined_behavior LOL!