Skip to content

Instantly share code, notes, and snippets.

@tuankiet65
Created October 26, 2018 15:44
Show Gist options
  • Save tuankiet65/9d11dd9c55fb9fd93ab93f4f441b18f1 to your computer and use it in GitHub Desktop.
Save tuankiet65/9d11dd9c55fb9fd93ab93f4f441b18f1 to your computer and use it in GitHub Desktop.
#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