Как объясняется в этом вопросе о вводе double (https://stackoverflow.com/questions/33269283/scanf-not-reading-in-double),
Вы сообщили компилятору неправду: при вводе %f обещает указатель на float. На самом деле вы передали указатель на double.
Либо замените формат на %lf, либо объявите входную переменную как float.
Обратите внимание, что правила формата у printf другие: он принимает %f для аргументов как float, так и double. Это работает, потому что аргументы повышаются до double, а не являются указателями.
Переведено с английского·Показать оригиналAs explained in this question about scanning doubles (https://stackoverflow.com/questions/33269283/scanf-not-reading-in-double),
Your claim to the compiler was false: for scanning, %f promises a pointer to float. What you actually supplied was a pointer to double.
Either switch to %lf or make the input a float.
Note that printf has different format rules, accepting %f with either float or double arguments. This works because the arguments undergo promotion to doubles instead of being pointers.