大学c语言,跟着书上写的,实在不知道哪里有问题
输入x的值,使用switch语句结构编程计算下列分段函数y的值。3x+6, x<-10
y= 2x-4, -10<=x<0
8x-9, 0<=x<10
5x+7, x>=10
#include<stdio.h>
int main()
{
int x,y;
printf("please input x:");
scanf("%d",&x);
switch(x<10)
{case 0: y=5*x+7;break;
case 1: switch(x<0)
{case 0: y=8*x-9;break;
case 1: switch(x<-10)
{case 0: y=2*x-4;break;
case 1: y=3*x+6;break;
}
}
}
printf("x=%f,y=%f\n",x,,y);
return 0;
}
D:\Microsoft Visual Studio\MyProjects\5654652\78788.c(8) : warning C4144: '<' : relational expression as switch expression
D:\Microsoft Visual Studio\MyProjects\5654652\78788.c(10) : warning C4144: '<' : relational expression as switch expression
D:\Microsoft Visual Studio\MyProjects\5654652\78788.c(12) : warning C4144: '<' : relational expression as switch expression
78788.obj - 0 error(s), 0 warning(s)