Answer to Question #304977 in C for Joyce

Question #304977

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

1
Expert's answer
2022-03-02T15:34:09-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS