C语言程序设计方面的问题

来源:百度知道 编辑:UC知道 时间:2024/06/10 09:47:29
#include <stdio.h>
main()
{ float x,s;
printf("x= \n");
scanf("%f",&x);
if(x<10)
s=0;
else
if(10<x<50)
int s=(x-10)*0.2;
else if(x>50);
int s=8+(x-50)*0.5;
printf("s=%f \n",s);
}
请问下这个程序哪里出错了....我查了半天也没查出来

#include <stdio.h>
main()
{ float x,s;
printf("x= \n");
scanf("%f",&x);
if(x<10)
s=0;
else
if(10<x&&x<50) /* 对于表达式10<x<50,无论x取何值,表达式永远为真*/
s=(x-10)*0.2; /* s前面的int去掉*/
else if(x>50) /* 把分号去掉*/
s=8+(x-50)*0.5;
printf("s=%f \n",s);
}

你前面定义了s是float了后面又写int当然不行了