#include<stdio.h>
#define HEG 0.54
float height(float father, float mother);
int main()
{
float father;
float mother;
float son;
printf("请输入父亲的身高: \n");
scanf("%f", &father);
printf("请输入母亲的身高: \n");
scanf("%f", &mother);
son = height(father, mother);
printf("预测儿子的身高: ");
printf("%.2f\n", son);
return 0;
}
float height(float father, float mother)
{
float son = (father + mother)*HEG;
return son;
}
显示
错误 C4996 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. heg g:\c\练习\heg\heg\heg.c 12
错误 C4996 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. heg g:\c\练习\heg\heg\heg.c 15
警告 C4244 “初始化”: 从“double”转换到“float”,可能丢失数据 heg g:\c\练习\heg\heg\heg.c 25