aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyder <hyder@hyderhadi.xyz>2025-08-10 19:34:54 +0300
committerHyder <hyder@hyderhadi.xyz>2025-08-10 19:34:54 +0300
commit6c96292759f1f29cc5b499039351bc91f5eb2daa (patch)
tree8e9f2b177e0af29e4dd8676292bdb434c05059fd
parent9d32762e395de7a867130ef4239dae830309d84d (diff)
I solved this exercise but i gotta be honest i used a bit of chatgpt :(
-rw-r--r--README5
-rw-r--r--VACC/VowelsAndConsonantCounter.c31
2 files changed, 34 insertions, 2 deletions
diff --git a/README b/README
index 0448e2f..09b1f54 100644
--- a/README
+++ b/README
@@ -7,5 +7,6 @@ CONTENTS
* CHECK FILES IN THE TREE TAB
-- The greatest common divisor exercise solution in ROOT/GCD/GCD.c
-- Hexadecimal to integer converter solution in ROOT/HTOI/HTOI.c \ No newline at end of file
+- The greatest common divisor exercise solution, in ROOT/GCD/GCD.c
+- Hexadecimal to integer converter solution, in ROOT/HTOI/HTOI.c
+- Vowels and consonants counter of a string, in ROOT/VACC/VowelsAndConsonantCounter.c \ No newline at end of file
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