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 scanfyet 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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -