im having trouble understanding why this occurs: with the following code;
#include <stdio.h>
int main()
{
double x=123;
printf("x is %f. Enter a new value for x.\n", x);
scanf("%f", &x);
printf("x is %f\n", x);
return 0;
}
when you enter 45678 as the new value for x, 'x is 123.000017' is printed. I know that this is fixed when you use %lf when scanning, but why does this happen when using %f?