Switch Statement
Switch Statement Is Used To Execute The Code From Multiple Conditions In C Language. Note The Switch Expression Must Be Of Integer Or Character Type. The Case Value Must Be Of Integer Or Character Constant. The Case Value Can Be Used In Switch Case. The Break Statement In Switch Case Is Not Must, It Is Optional. If There Is No Break Statement Found In The Switch Case, All The Cases Will Be Executed After Matching The Case Value, It Is Known As All Through State Of C Switch Statement. Example Write A Program To Find The Given Character Is Vowel (Or) Consonant. #include #include voidmain() { char c; clrscr(); printf("Enter Any Alphabet : "); scanf("%c",&c); switch(c) { case 'a': printf("%c is a vowel : ",c); break; case 'e': printf("%c is a vowel :",c); break; case 'i': printf("%c is vowel : ",c); break; case 'o': printf("%d is a vowel : ",c); break: case 'u': printf("%d is a vowel : ",c); break; default: printf("%c is a consonant",c); } getch(); } Result Enter Any Alphabet : b b is a consonant Read the full article














