橘子味的心
标题:switch 语句

switch 语句

#include <stdio.h>



int main () {



   /* local variable definition */

   char grade = 'B';



   switch(grade) {

      case 'A' :

         printf("Excellent!\n" );

         break;

      case 'B' :

      case 'C' :

         printf("Well done\n" );

         break;

      case 'D' :

         printf("You passed\n" );

         break;

      case 'F' :

         printf("Better try again\n" );

         break;

      default :

         printf("Invalid grade\n" );

   }



   printf("Your grade is  %c\n", grade );



   return 0;

}

目录

分类