From 6c96292759f1f29cc5b499039351bc91f5eb2daa Mon Sep 17 00:00:00 2001 From: Hyder Date: Sun, 10 Aug 2025 19:34:54 +0300 Subject: I solved this exercise but i gotta be honest i used a bit of chatgpt :( --- VACC/VowelsAndConsonantCounter.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 VACC/VowelsAndConsonantCounter.c (limited to 'VACC') 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 + +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 -- cgit v1.2.3