+ 3
What is the difference between %d and %f in c programming?
4 Réponses
+ 12
In addition to Edwin's reply, if you use %d to print 5.26, you'll get an unexpected value.
https://stackoverflow.com/questions/7480097/what-happens-to-a-float-variable-when-d-is-used-in-a-printf
+ 7
To print a integer value we use %d like 5
For printing float value we use %f like 5.26
+ 6
%d and %f are format specifiers. %d is used for integer(-3,-100,3,100,etc). And %f is used for float(10.6,-39.0,etc).
+ 5
%i can also be used for integers.