kucheasysa

vowel consonants

Jun 6th, 2023
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int isVowel(char ch) {
  4. ch = tolower(ch);
  5. if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
  6. return 1;
  7. return 0;
  8. }
  9.  
  10. int main() {
  11. char input[100];
  12. int vowels = 0, consonants = 0, i;
  13.  
  14. printf("Enter a character array: ");
  15. fgets(input, sizeof(input), stdin);
  16.  
  17. for (i = 0; input[i] != '\0'; i++) {
  18. if ((input[i] >= 'a' && input[i] <= 'z') || (input[i] >= 'A' && input[i] <= 'Z')) {
  19. if (isVowel(input[i])) {
  20. vowels++;
  21. } else {
  22. consonants++;
  23. }
  24. }
  25. }
  26.  
  27. printf("Vowels: %d\n", vowels);
  28. printf("Consonants: %d\n", consonants);
  29.  
  30. return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment