Switch Statement
Sample output:
Enter any one of the alphabets a,b,or c:A
You are in case A
Sample output 1:
Enter any one of the alphabets a,b,or c:a
You are in case a
Sample output 2:
Enter any one of the alphabets a,b,or c:b
You are in case b
#include <stdio.h>
int main(void) {
  printf("Enter any one of the alphabets a,b,or c:");
  char c;
  scanf("%c", &c);
  printf("You are in case %c\n", c);
  switch(c) {
    case 'a':
    case 'A':
      printf("%d\n", 1);
      break;
    case 'b':
    case 'B':
      printf("%d\n", 2);      
      break;
    case 'c':
    case 'C':
      printf("%d\n", 3);
      break;
  }
  return 0;
}
Comments