Undefined behavior. The %d specifier tells printf to read a 4-byte int from its variadic argument area, but the actual argument is a float (or double, since floats are promoted). The bit pattern gets reinterpreted as if it were an int, producing nonsense output. Worse, on some calling conventions, the mismatch can shift printf's view of subsequent arguments, corrupting unrelated values in the same call. Always match the format specifier to the argument type, %d for int, %f for float/double, %c for char.
Programming Fundamentals · Interview question
What happens if you pass a float to printf("%d", ...)?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Variables & Data Types
Named boxes that hold a value. Pick a type, declare, assign, and learn why C makes you say what kind of thing each box holds.