In ternary operator of type (x ? y : z), type of expression is type of y and z. If y and z don't have common type, then one is converted to other (according to standard conversion rules) to make type same.
Now in your question, type of a is float, and type of 3 is int, so 3 is converted to float i.e. to 3.0, but you are printing a float value with %d format specifier, which is undefined behavior, and hence the garbage value. Try %f instead if %d, it will print correct value.