Switch with default : Switch « Language Basics « C / ANSI-C






Switch with default

  
#include <stdio.h>
#include <conio.h>

int main(void)
{
  char ch;

  printf("Enter the letter: ");
  ch = getche();

  switch(ch) {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
    case 'y':
      printf(" is a vowel\n");
      break;
    default:
      printf(" is a consonant");
  }

  return 0;
}

           
       








Related examples in the same category

1.a simple 4 function calculator
2.Switch demo
3.How to use switch: number
4.How to use switch: char
5.Switch: char and nested if
6.Switch inside for loop
7.Switch with int case
8.Switch with char case
9.Get three input at the same time: scanf
10.Console menu: switch with char case