switchcase语句例子是什么

switch case语句例子如下:
#include <stdio.h>int main(){int a;printf("Input integer number:");scanf("%d",&a);if(a==1) 。 {printf("Mondayn") 。
}else if(a==2){printf("Tuesdayn");}else if(a==3){printf("Wednesdayn");}else if(a==4) 。 {printf("Thursdayn");}else if(a==5) 。
{printf("Fridayn");}else if(a==6){printf("Saturdayn");}else if(a==7) 。 {printf("Sundayn");}else{printf("errorn");}return 0;} 。

switchcase语句例子是什么

文章插图

Switch用在编程中 , 如C语言中它经常跟Case一起使用 , 是一个判断选择代码 。 其功能就是控制流程流转的 。
直线翻译:switch语句 , 即“切换”语句;case即“情况” 。
switch语句的语法如下(switch , case , break和default是关键字) 。
【switchcase语句例子是什么】switch ( 变量表达式 ){case 常量1 :语句;break;case 常量2 :语句;break;case 常量3 :语句;break;...case 常量n:语句;break;default :语句;break;} 。

    推荐阅读