if i change %f to %d a new number appear i dont know why? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

if i change %f to %d a new number appear i dont know why?

#include <stdio.h> int main() { const double PI = 3.14; printf("%f", PI); return 0; } if i change %f to %d a new number appear i dont know why?

1st Aug 2019, 6:24 PM
Kuleep Bhogal
Kuleep Bhogal - avatar
1 Antwort
0
%d stands for decimal and it expects an argument of type int (or some smaller signed integer type that then gets promoted). Floating-point types float and double both get passed the same way (promoted to double) and both of them use %f.
1st Aug 2019, 6:31 PM
Brave Tea
Brave Tea - avatar