#include <stdio.h> //包含头文件
#define HEG 0.54 //定义常量
float height(float father, float monther); //函数声明
int main() //主函数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; //返回整型0
}
float height(float father,float monther) //定义计算儿子身高的函数
{
float son=(father+mother)*HEG; //具体计算儿子的身高
return son; //返回儿子的身高
}
float son=(father+mother)*HEG; //具体计算儿子的身高
这里的mother与参数monther不一致,改成monther就好了
float height(float father,float monther) { //定义计算儿子身高的函数
float son=(father+monther)*HEG; //具体计算儿子的身高
return son; //返回儿子的身高
}
你写错了一个单词: mother