Mega Code Archive

 
Categories / C Tutorial / Statement
 

Use switch structure to evaluate characters

#include <stdio.h> main(){     char iResponse = 'A';     printf("input(a or A or B or b or c or C):");     scanf("%d", &iResponse);     switch (iResponse) {       case 'a': case 'A':         printf ("\nYou selected the character a or A\n");         break;       case 'b': case 'B':         printf("You selected the character b or B\n");         break;       case 'c': case 'C':         printf("You selected the character c or C\n");         break;     } }