vowels.c 987 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // vowels.c -- uses multiple labels
  2. #include <stdio.h>
  3. int main(void)
  4. {
  5. char ch;
  6. int a_ct, e_ct, i_ct, o_ct, u_ct;
  7. a_ct = e_ct = i_ct = o_ct = u_ct = 0;
  8. printf("Enter some text; enter # to quit.\n");
  9. while ((ch = getchar()) != '#')
  10. {
  11. switch (ch)
  12. {
  13. case 'a' :
  14. case 'A' : a_ct++;
  15. break;
  16. case 'e' :
  17. case 'E' : e_ct++;
  18. break;
  19. case 'i' :
  20. case 'I' : i_ct++;
  21. break;
  22. case 'o' :
  23. case 'O' : o_ct++;
  24. break;
  25. case 'u' :
  26. case 'U' : u_ct++;
  27. break;
  28. default : break;
  29. } // end of switch
  30. } // while loop end
  31. printf("number of vowels: A E I O U\n");
  32. printf(" %4d %4d %4d %4d %4d\n",
  33. a_ct, e_ct, i_ct, o_ct, u_ct);
  34. return 0;
  35. }