Resolve incorrect double variable output and memory corruption caused by using the wrong format specifier with scanf in C.