Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int is_vowel(char c)
- {
- int i;
- int ret = 0;
- char vow[10] = {'a', 'e', 'i', 'o', 'u',
- 'A', 'E', 'I', 'O', 'U'};
- for (i = 0; i < 10; i++)
- if (vow[i] == c)
- ret = 1;
- return ret;
- }
- int is_alpha(char c)
- {
- if ((c >= 'A' & c <= 'Z')
- | (c >= 'a' & c <= 'z'))
- return 1;
- return 0;
- }
- int main(void)
- {
- int i;
- int cc = 0;
- int cv = 0;
- char *text = malloc(256);
- char *p = text;
- printf("Input text: ");
- fgets(text, 255, stdin);
- while(*p) {
- if(is_alpha(*p))
- if(is_vowel(*p))
- cv++;
- else
- cc++;
- p++;
- }
- printf("Consonant : %d, Vowel : %d\n", cc, cv);
- free(text);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement