-
-
Save tuankiet65/9d11dd9c55fb9fd93ab93f4f441b18f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ctype.h> | |
#include <stdio.h> | |
char c; | |
int vowels, consonants, others; | |
int main() { | |
printf("Enter a string: "); | |
do { | |
c = getchar(); | |
c = toupper(c); | |
if (isupper(c)) { | |
switch (c) { | |
case 'A': | |
case 'E': | |
case 'I': | |
case 'O': | |
case 'U': | |
vowels++; | |
break; | |
default: | |
consonants++; | |
} | |
} else { | |
others++; | |
} | |
} while (c != '\n'); | |
printf("Vowels count: %d\n", vowels); | |
printf("Consonants count: %d\n", consonants); | |
printf("Non-alphabetics count: %d\n", others); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment