我是靠谱客的博主 害怕御姐,这篇文章主要介绍在switch case 语句中能否使用continue 关键字?为什么?,现在分享给大家,希望可以做个参考。

在switch case 语句中能否使用continue 关键字?为什么?
#include <stdio.h>  
int main()  
{  
    int a;  
    printf("input integer number:      ");  
    scanf("%d",&a);  
    switch (a)  
    {  
        case 1:printf("Mondayn");  
        case 2:printf("Tuesdayn");  
        case 3:printf("Wednesdayn");  
        case 4:printf("Thursdayn");  
        continue;  
        case 5:printf("Fridayn");  
        case 6:printf("Saturdayn");  
        case 7:printf("Sundayn");  
        default:printf("errorn");  
    }  
    return 0;  

编译不通过!!!
答:
1)不能,除非外面有循环。
2)continue语句的作用是跳过循环本中剩余的语句,并到循环末尾。
3)continue语句只用在for、while、do-while等循环体中, 常与if条件语句一起使用, 用来加速循环。

最后

以上就是害怕御姐最近收集整理的关于在switch case 语句中能否使用continue 关键字?为什么?的全部内容,更多相关在switch内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(130)

评论列表共有 0 条评论

立即
投稿
返回
顶部