Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int isVowel(char ch) {
- ch = tolower(ch);
- if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
- return 1;
- return 0;
- }
- int main() {
- char input[100];
- int vowels = 0, consonants = 0, i;
- printf("Enter a character array: ");
- fgets(input, sizeof(input), stdin);
- for (i = 0; input[i] != '\0'; i++) {
- if ((input[i] >= 'a' && input[i] <= 'z') || (input[i] >= 'A' && input[i] <= 'Z')) {
- if (isVowel(input[i])) {
- vowels++;
- } else {
- consonants++;
- }
- }
- }
- printf("Vowels: %d\n", vowels);
- printf("Consonants: %d\n", consonants);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment