default: printf("\nIn switch case default (%d)", i); break;
17
}
18
}
19
20
printf("\n\n\n");
21
char*str = "bethecoder";
22
23
for( i = 0 ; i < 10; i++) {
24
25
switch(str[i]){
26
case'b':
27
case'e':
28
case't':
29
case'h':
30
case'd': printf("\nIn switch case %c", str[i]); break;
31
default: printf("\nIn switch case default (%c)", str[i]); break;
32
}
33
}
34
35
36
37
getch();
38
return0;
39
}
It gives the following output,
In switch case 0
In switch case 1
In switch case 2
In switch case 3
In switch case default (4)
In switch case b
In switch case e
In switch case t
In switch case h
In switch case e
In switch case default (c)
In switch case default (o)
In switch case d
In switch case e
In switch case default (r)