zoukankan      html  css  js  c++  java
  • C语言break语句

    break语句不能用于循环语句和switch语句之外的任何其他语句中;

    breakh中断switch

    break如果用于循环,是用来终止循环;break如果用于switch,则是用于终止switch。

    break不能直接用于if,除非if是属于循环内部的一个子句(这种情况break用于终止循环)。

    #include <stdio.h>
     
    int main ()
    {
       /* local variable definition */
       int a = 10;
    
       /* while loop execution */
       while( a < 20 )
       {
          printf("value of a: %d
    ", a);
          a++;
          if( a > 15)
          {
             /* terminate the loop using break statement */
              break;
          }
       }
     
       return 0;
    }

    当上述代码被编译和执行时,它产生了以下结果:

    value of a: 10
    value of a: 11
    value of a: 12
    value of a: 13
    value of a: 14
    value of a: 15
  • 相关阅读:
    String
    Map和Set
    js的栈与堆
    js的私有属性
    随便谈一谈原型
    前端页面优化提速
    nth-child和nth-of-type
    重复输出字符串
    闭包
    mongodb内嵌文档的查询
  • 原文地址:https://www.cnblogs.com/prayer521/p/5618085.html
Copyright © 2011-2022 走看看