#include <stdio.h>
int main(void)
{
float weight,value;
//假设白金的价格为每(金衡)盎司¥1700,单位换算机制详见P34
value=1700*weight*14.5833;
printf("Are you worth you weight in platinum?\n");
printf("let's check it out.\n");
printf("Please enter your weight in pounds.\n");
//新函数scanf:用于获取用户输入
getchar();
scanf_s("%f",&weight);
getchar();
printf("So your weight in platinum is worth $%.2f.\n",value);
printf("You are easily worth that! If platinum prices drop,\n");
printf("eat more to maintain your value.\n");
return 0;
}
第16行代码中value的值无法赋到转换说明处,显示结果仍为0.00