diff options
| author | Hyder <hyder@hyderhadi.xyz> | 2025-08-10 19:34:54 +0300 |
|---|---|---|
| committer | Hyder <hyder@hyderhadi.xyz> | 2025-08-10 19:34:54 +0300 |
| commit | 6c96292759f1f29cc5b499039351bc91f5eb2daa (patch) | |
| tree | 8e9f2b177e0af29e4dd8676292bdb434c05059fd /VACC/VowelsAndConsonantCounter.c | |
| parent | 9d32762e395de7a867130ef4239dae830309d84d (diff) | |
I solved this exercise but i gotta be honest i used a bit of chatgpt :(
Diffstat (limited to 'VACC/VowelsAndConsonantCounter.c')
| -rw-r--r-- | VACC/VowelsAndConsonantCounter.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/VACC/VowelsAndConsonantCounter.c b/VACC/VowelsAndConsonantCounter.c new file mode 100644 index 0000000..8cf0554 --- /dev/null +++ b/VACC/VowelsAndConsonantCounter.c @@ -0,0 +1,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; +}
\ No newline at end of file |
