using if-statement instead of switch-statement
This commit is contained in:
parent
4c87139ab0
commit
9f7dd8283f
27
ex13.c
27
ex13.c
@ -22,36 +22,23 @@ int main(int argc, char *argv[])
|
|||||||
letter = (char)(i_letter + up_low_sep);
|
letter = (char)(i_letter + up_low_sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(letter) {
|
if (letter == 'a') {
|
||||||
case 'a':
|
|
||||||
printf("%d: 'a'\n", i);
|
printf("%d: 'a'\n", i);
|
||||||
break;
|
} else if (letter == 'e') {
|
||||||
|
|
||||||
case 'e':
|
|
||||||
printf("%d: 'e'\n", i);
|
printf("%d: 'e'\n", i);
|
||||||
break;
|
} else if (letter == 'i') {
|
||||||
|
|
||||||
case 'i':
|
|
||||||
printf("%d: 'i'\n", i);
|
printf("%d: 'i'\n", i);
|
||||||
break;
|
} else if (letter == 'o') {
|
||||||
|
|
||||||
case 'o':
|
|
||||||
printf("%d: 'o'\n", i);
|
printf("%d: 'o'\n", i);
|
||||||
break;
|
} else if (letter == 'u') {
|
||||||
|
|
||||||
case 'u':
|
|
||||||
printf("%d: 'u'\n", i);
|
printf("%d: 'u'\n", i);
|
||||||
break;
|
} else if (letter == 'y') {
|
||||||
|
|
||||||
case 'y':
|
|
||||||
if (i > 2) {
|
if (i > 2) {
|
||||||
printf("%d: 'Y'\n", i);
|
printf("%d: 'Y'\n", i);
|
||||||
} else {
|
} else {
|
||||||
printf("%d: 'Y' isn't a vowel this time\n", i);
|
printf("%d: 'Y' isn't a vowel this time\n", i);
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
|
|
||||||
default:
|
|
||||||
printf("%d: '%c' is not a vowel\n", i, letter);
|
printf("%d: '%c' is not a vowel\n", i, letter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user