zoukankan      html  css  js  c++  java
  • <C Primer Plus>12 switch and break continue

    #include <stdio.h>
    #define STOP '#'
    int main(void){
        char ch;
    
        printf("Please input the lower
    ");
        printf("input the # to stop.
    ");
        while ((ch = getchar()) != STOP){
            if (islower(ch)){
                switch (ch){
                case 'a':
                    printf("apple,a fruit of red.
    ");
                    break;
                case 'b':
                    printf("banan, a fruit of yellow.
    ");
                    break;
                case 'c':
                    printf("coati, recoonlike mammal.
    ");
                    break;
                case 'd':
                    printf("desman,aquatic molelike critter.
    ");
                    break;
                case 'e':
                    printf("echidna,the spiny anteater.
    ");
                    break;
                case 'f':
                    printf("fisher ,brownish marten.
    ");
                    break;
                }        
            }
            else{
                printf("I recongnize only lowercase letters.
    ");
            }
            
        }
        printf("Bye!
    ");
        return 0;
    }

    REMEBER:

    1 continue causes the rest of an iteration to be skipped and the next iteration to be started.

    2.break causes the program to break free of the loop that encloses it and to proceed to the next stage of the program.

    3 swtich(integer expression1){

      case constant1:

          statements

          break;//depend on your meaning 

      case constant2:

          statements

          break;

      default:

          statements

          break;

    }

  • 相关阅读:
    .htaccess
    windows快速搭建wamp环境,多站点域名访问
    require与include的区别
    PHP常用操作的字符串函数
    高效做事的习惯
    成功?!
    面向对象程序设计
    失落 绝望
    jquery学习收获
    XML操作类
  • 原文地址:https://www.cnblogs.com/michael2016/p/6665206.html
Copyright © 2011-2022 走看看