为什么这个代码运行到最后输出不了结果就结束了

来源:4-2 分支结构之简单if-else语句

qq_涵雨_jmEU57

2018-10-25 14:58

#include<stdio.h>
int main(void)
{
float Height;
float faHeight;
float moHeight;
char sex;
char sport;
char diet;
printf("Are you a boy(m) or a girl(f)\n");
scanf(" %c",&sex);
printf("please enter your father's height\n");
scanf("%f",&faHeight);
printf("please enter your mother's height\n");
scanf("%f",&moHeight);
if(sex=='f'||sex=='F')
{
    Height=(faHeight+moHeight)*0.54;
    
}
else
{
        Height=(faHeight*0.923+moHeight)/2;
}


printf("do you have a good diet(y/n)\n");
scanf(" %c",&diet);
if(diet=='y'||diet=='Y');
{
    Height = Height*1.015;
}
printf("do you like sport(y/n)\n");
scanf(" %c",sport);
if(sport=='y'||sport=='Y')
{
    Height = Height*1.02;
}
printf("your future Height will be %f\n",Height);
return 0;

}

写回答 关注

1回答

  • NuMbing
    2018-10-25 21:39:47
    已采纳

    倒数第7行,sport没有取地址。加一个&

C语言入门

C语言入门视频教程,带你进入编程世界的必修课-C语言

926023 学习 · 20793 问题

查看课程

相似问题