Doubt in switch case
#include<stdio.h> #include<stdlib.h> int main() { char ch; while(1) { printf("enter char value:"); scanf("%c",&ch); switch(ch) { case 'a': printf("a\n"); break; case 'b':printf("b\n"); break; case 'e':exit(0); break; default:printf("chose valid char\n"); } } } Output: enter char value:a a enter char value:chose valid char enter char value:e -------------------------------- Process exited after 49.66 seconds with return value 0 Press any key to continue . . . Friends my doubt is ....I have given a as input ....it's fine. But after that, why is it going to default.........?