私はCを学ぼうとしていて、次の小さなプログラムを考え出しました。
#include "stdafx.h"
void main()
{
double height = 0;
double weight = 0;
double bmi = 0;
printf("Please enter your height in metres\n");
scanf_s("%f", &height);
printf("\nPlease enter your weight in kilograms\n");
scanf_s("%f", &weight);
bmi = weight/(height * height);
printf("\nYour Body Mass Index stands at %f\n", bmi);
printf("\n\n");
printf("Thank you for using this small program. Press any key to exit");
getchar();
getchar();
}
プログラムは完全にコンパイルされますが、プログラムによって返される答えは意味がありません。高さを1.8、体重を80とすると、bmiは1.#NF00のようになり、意味がありません。
私は何が間違っているのですか?