根据父母身高预测儿子身高C语言代码
#include <stdio.h> //预处理命令//
#define HEG 0.54//定义常量0.54//
float height(float father,float mother);
int main()
{
float father;
float mother;
float son;
printf("please input father's height:\n");
scanf("%f",&father);
printf("please input mother's height:\n");
scanf("%f",&mother);
son=height(father,mother);
printf("caculate son's height:");
printf("%.2f\n",son);
}
float height(float father,float mother)
{
float son =(father+mother)*HEG;
return son;
}
运行如下: