You are using the format specifier for an int and passing an argument of type double.
printf("%d %d %d %d\n", a,b,c,d);
instead of
printf("%f %d %d %d\n", a,b,c,d);
When the arguments to printf don't correspond to the conversion specifier, you run into unspecified behavior.
From http://en.cppreference.com/w/cpp/io/c/fprintf
arguments specifying data to print. If any argument is not the type expected by the corresponding conversion specifier, or if there are less arguments than required by format, the behavior is undefined. If there are more arguments than required by format, the extraneous arguments are evaluated and ignored