From 9f7dd8283ff59d07f75ae94c120735b50df2e099 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Tue, 13 Sep 2011 23:07:15 -0400 Subject: [PATCH] using if-statement instead of switch-statement --- ex13.c | 49 ++++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/ex13.c b/ex13.c index 33356ad..b6e2ddd 100644 --- a/ex13.c +++ b/ex13.c @@ -22,37 +22,24 @@ int main(int argc, char *argv[]) letter = (char)(i_letter + up_low_sep); } - switch(letter) { - case 'a': - printf("%d: 'a'\n", i); - break; - - case 'e': - printf("%d: 'e'\n", i); - break; - - case 'i': - printf("%d: 'i'\n", i); - break; - - case 'o': - printf("%d: 'o'\n", i); - break; - - case 'u': - printf("%d: 'u'\n", i); - break; - - case 'y': - if (i > 2) { - printf("%d: 'Y'\n", i); - } else { - printf("%d: 'Y' isn't a vowel this time\n", i); - } - break; - - default: - printf("%d: '%c' is not a vowel\n", i, letter); + if (letter == 'a') { + printf("%d: 'a'\n", i); + } else if (letter == 'e') { + printf("%d: 'e'\n", i); + } else if (letter == 'i') { + printf("%d: 'i'\n", i); + } else if (letter == 'o') { + printf("%d: 'o'\n", i); + } else if (letter == 'u') { + printf("%d: 'u'\n", i); + } else if (letter == 'y') { + if (i > 2) { + printf("%d: 'Y'\n", i); + } else { + printf("%d: 'Y' isn't a vowel this time\n", i); + } + } else { + printf("%d: '%c' is not a vowel\n", i, letter); } } }