设 float w=0; int x=1,y=2; char z='3';,下列语句错误的是( )。
A.switch(x)
{ case 0:
case 1:
case 2:
default:;
}
B.switch(y)
{ case 0:
case 1:
case 2:
default:;
}
C.switch(z)
{ case 0:
case 1:
case 2:
default:;
}
D.switch(w)
{ case 0:
case 1:
case 2: default:;
}
【答案解析】
switch(表达式),表达式常用的是字符型或整型表达式,w是单精度类型,所以答案选D。参见教材P68。
本题知识点:选择结构的程序设计,
自考365网小编精心为广大自考学员整理的相关历年
试题及答案解析,想了解相关自考试题请持续关注自考365网校。
让自考更有氛围,想加入自考365订阅号请添加zhengbaozikao365