I am confused about the following behavior in C.
#include
int main() {
float a = 3.14; // literal is double
float b = 3.14f; // literal is float
printf("%f\n", a);
printf("%f\n", b);
}
So my confusion is:
If one literal is double and the other is float, why do both print the same output?
Does the implicit conversion from double → float lose precision? If yes, why can’t I see the difference in
printf("%f")?Is there any practical difference between writing
3.14vs3.14ffor a float variable?
I want to understand the exact reason from a C programming perspective—how literals, implicit conversions, and printf formatting interact.
Thanks.