c - Adding 2 doubles and print them -
iam new c , have problem adding , printing doubles in 09.3f format. code:
#include <stdio.h> int main(int argc, char **argv) { double d, m, c; scanf("%1f", &d); scanf("%1f", &m); c = d + m; printf("%09.3f\n", c); }
and have typed twice scanf
yet can insert 1 number, why that? printf 00000.000
example: d = 5,125 , m = 1.256, want c be: 00006.381
here, might input buffer problems scanf. so, can add space
in scanf
. like,
scanf("%lf", &d); scanf(" %lf", &m);
also, use %lf
in scanf
instead of %1f
.
Comments
Post a Comment