using if-statement instead of switch-statement

This commit is contained in:
Dan Buch 2011-09-13 23:07:15 -04:00
parent 4c87139ab0
commit 9f7dd8283f

27
ex13.c
View File

@ -22,36 +22,23 @@ int main(int argc, char *argv[])
letter = (char)(i_letter + up_low_sep);
}
switch(letter) {
case 'a':
if (letter == 'a') {
printf("%d: 'a'\n", i);
break;
case 'e':
} else if (letter == 'e') {
printf("%d: 'e'\n", i);
break;
case 'i':
} else if (letter == 'i') {
printf("%d: 'i'\n", i);
break;
case 'o':
} else if (letter == 'o') {
printf("%d: 'o'\n", i);
break;
case 'u':
} else if (letter == 'u') {
printf("%d: 'u'\n", i);
break;
case 'y':
} else if (letter == 'y') {
if (i > 2) {
printf("%d: 'Y'\n", i);
} else {
printf("%d: 'Y' isn't a vowel this time\n", i);
}
break;
default:
} else {
printf("%d: '%c' is not a vowel\n", i, letter);
}
}