C examples for Statement:switch
Use multiple case labels for a given statement
#include <stdio.h> int main(void) { char ch;//from w ww. java 2s. c o m int aCount, eCount, iCount, oCount, uCount; aCount = eCount = iCount = oCount = uCount = 0; printf("Enter some text; enter # to quit.\n"); while ((ch = getchar()) != '#') { switch (ch) { case 'a' : case 'A' : aCount++; break; case 'e' : case 'E' : eCount++; break; case 'i' : case 'I' : iCount++; break; case 'o' : case 'O' : oCount++; break; case 'u' : case 'U' : uCount++; break; default : break; } } printf("number of vowels: A E I O U\n"); printf(" %4d %4d %4d %4d %4d\n", aCount, eCount, iCount, oCount, uCount); return 0; }