我正在尝试学习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 这没有意义。
我究竟做错了什么?