main( )
{ char k; int i;
for(i=1;i<3;i++)
{ scanf(“%c”,&k);
switch(k)
{ case ‘0’: printf(“another\n”);
case ‘1’: printf(“number\n”);
}
}
}程序运行时,从键盘输入:01<回车>,程序执行后的输出结果是
another
number
number
if(a>b>c) 当a=5,b=4,c=3时,为假,因为a>b为真,所以就等于1>c,假。
为了避免嵌套的条件语句if-else的二义性,C语言规定else总是与其之前最近的未曾配对的if 配对
if(a=12)将a赋值为12,而不管a之前的数值
int x=10,y=20,t=0;
if(x==y)t=x;x=y;y=t;
printf("%d,%d\n",x,y);
该代码表示,x等于y时执行t=x,而后面的x=y始终执行