double d;
scanf("%f", &d);
printf("%f", d);
result:
input: 10.3
output: 0.00000
Why? i think output should be 10.3 visual studio 2008.
For scanf(), %f is for a float. For double, you need %lf. So,
#include <stdio.h>
main() {
double d;
scanf("%lf", &d);
printf("%f\n", d);
}
with input 10.3 produces 10.300000.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With