aboutsummaryrefslogtreecommitdiff
path: root/VACC/VowelsAndConsonantCounter.c
blob: 8cf05540906a4fe37703b438eb4abbe2ee272da1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# include <stdio.h>

void countConsonantandVowel(char input[1000]) {
  char vowels[10] = "aeiouAEIOU";
  int count_vowels = 0;
  int count_consonants = 0;
  int spaces = 0;
  for (int i = 0; input[i] != '\0'; ++i) {
    int flag_vowel = 0;
    for (int n = 0; n < 10; ++n) {
      if (input[i] == vowels[n]) {
        count_vowels += 1;
        flag_vowel = 1;
        break;
      }
    }
    if (input[i] == ' ' || input[i] == '\n' || input[i] == '\t') {
      spaces += 1;
    }
    else if (!flag_vowel) {
      count_consonants += 1;
    }
  }
  printf("THE VOWELS ARE: %d, THE CONSONANTS ARE: %d, THE WHITE SPACE COUNT: %d\n\n", count_vowels, count_consonants, spaces);
}

int main () {
  char INPUT[1000] = "hyder hadi abd-alghani";
  countConsonantandVowel(INPUT);
  return 0;
}