C examples for Statement:while
The switch statement checks for equality between an integer and a series of case labels, and switch execution to the matching case.
It can end with a default label for handling all other cases.
#include <stdio.h> int main(void) { int x = 0;/*from www .ja v a2 s .co m*/ switch (x) { case 0: printf("x is 0"); break; case 1: printf("x is 1"); break; default: printf("x is not 0 or 1"); break; } }
The break keyword skips the rest of the switch cases.
If the break is missing, execution will fall through to the next case.