Categories
News Review

floating point – When to use %d and %f in C? – Stack Overflow

For printf, %d expects its corresponding argument to have type int, where %f expects it to have type float or double. The result of an arithmetic expression involving and int and a float will be float, so you will need to use %f in this case.