iOS training------My C language notes, look forward to communicating with you!
#include <stdio.h>/*switch (value) {case value 1: statement 1; Break Case value 2: statement 2; Break Default: Statement 3; Break } */intMain () {//int a = 10; //Break : Exit the entire switch statement//If there is no break behind the case, the statement in all subsequent statements is executed until a break is encountered /*int b = 10; Switch (a) {case 10:printf ("a\n"); b++; Case 5:printf ("b\n"); b++; Case 0:printf ("c\n"); b++; Break default:printf ("d\n"); Break } printf ("B's value is%d\n", b);*/ //output display; Athe value of B C B isCharc ='+'; intA =Ten; intb = -; //if you want to define a new variable after the case, you must enclose it in curly braces {} Switch(c) { Case '+': { intsum = a +b; printf ("and is%d\n", sum);//and yes . Break; } Case '-': { intminus = A-b; printf ("the difference is%d\n .", minus); Break; } } return 0;}
"Good Programmer's note sharing" C language switch statement