if 语句 一个 if 语句 由一个表达式后跟一个或多个语句组成;
if else 语句 一个 if 语句 后可跟一个可选的 else 语句,else 语句在表达式为假时执行;
嵌套 if 语句 可以在一个 if 或者 else if 语句内使用另一个 if 或者 else if 语句;
switch 语句 一个 switch 语句允许测试一个变量等于n个结果时;
嵌套 switch 语句 可以在一个 switch 语句内使用另一个 switch 语句;
if为如果else为否则当有多项选择时可用if else套用列如:if( a>5);
{ printf("haha")}
if else;
{printf(“wawa”);}
else ;
{printf("hehe")}
switulch为主动选择语句case为多项持续选择语句列如:
#include <stdio.h>
int main ()
{
switch('c' )
{
case 'a':
printf("1\n" );
break;
case 'b':
printf("2\n" );
break;
case 'c':
printf(" 3\n" );
break;
default
printf("5\n" );
}
return 0;
}
当上面的代码被编译和执行时,它会产性下列结果:3
switch可套用