Guys can you help me on this, We should create a c program about finding each vowels and consonants in a word put by user | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Guys can you help me on this, We should create a c program about finding each vowels and consonants in a word put by user

Ex. Word, the output: W-consonant O-vowel R-consonant D-Consonant

1st Nov 2020, 8:52 AM
Cj Pallar
Cj Pallar - avatar
20 Answers
+ 11
Where's your attempt??
1st Nov 2020, 8:54 AM
🔰Saurabh🔰
🔰Saurabh🔰 - avatar
+ 5
Here it is, but it only display the first letter of the word #include <stdio.h> int main() { char c; int lowercase_vowel, uppercase_vowel; printf("Enter an alphabet: "); scanf("%c", &c); // evaluates to 1 if variable c is a lowercase vowel lowercase_vowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'); // evaluates to 1 if variable c is a uppercase vowel uppercase_vowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'); // evaluates to 1 (true) if c is a vowel if (lowercase_vowel || uppercase_vowel) printf("%c is a vowel.", c); else printf("%c is a consonant.", c); return 0; }
1st Nov 2020, 8:56 AM
Cj Pallar
Cj Pallar - avatar
+ 5
Cj Pallar it is the best to move your code to code bits and attach the link in question Description
1st Nov 2020, 12:11 PM
Ananiya Jemberu
Ananiya Jemberu - avatar
+ 3
Cj Pallar please paste and save the code in code playground or code bits and then share it here with the community. Your program is made to read, check and print the result for only one character. Put everything into a loop running till there are no more characters to read: while( scanf("%c", &c) == 1 ) { ...entire program... }
1st Nov 2020, 12:32 PM
Davide
Davide - avatar
1st Nov 2020, 12:52 PM
Flash
+ 3
Szaky spaces are considered consonant
1st Nov 2020, 8:10 PM
Davide
Davide - avatar
+ 2
Flash you don't need the variable fV. After you check if c is a vowel you can do just else if (isalpha(*pS)) { printf("%c-consonant\n", toupper(*pS)); }
1st Nov 2020, 1:27 PM
Davide
Davide - avatar
+ 2
Flash you are righ sorry. I should have tried it before telling you anything. I thought the two if were one after the other
1st Nov 2020, 4:30 PM
Davide
Davide - avatar
1st Nov 2020, 8:02 PM
Szaky
Szaky - avatar
+ 2
\n as well is consonant Szaky in your code
1st Nov 2020, 8:22 PM
Flash
+ 2
Davide and Flash Thanks! I fix it!
1st Nov 2020, 8:25 PM
Szaky
Szaky - avatar
1st Nov 2020, 8:57 AM
Cj Pallar
Cj Pallar - avatar
1st Nov 2020, 8:57 AM
Cj Pallar
Cj Pallar - avatar
+ 1
well Davide could you post the code? I still think I need it, but show your code so I can see
1st Nov 2020, 2:59 PM
Flash
+ 1
Davide no worries
1st Nov 2020, 4:38 PM
Flash
+ 1
nice Szaky .. a bit different
1st Nov 2020, 8:26 PM
Flash
+ 1
Thanks guys
2nd Nov 2020, 6:37 AM
Cj Pallar
Cj Pallar - avatar
0
Here it is
2nd Nov 2020, 6:53 AM
Cj Pallar
Cj Pallar - avatar
0
But it only recognize the first letter of the word
2nd Nov 2020, 6:53 AM
Cj Pallar
Cj Pallar - avatar