the below prgrm is to find how many vowels in a string using pointers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

the below prgrm is to find how many vowels in a string using pointers

when i enter a string 'eee' it shows the total vowel is 4,can anyone help me to rewrite the prgrm with correct output https://code.sololearn.com/cH64wVKC8H5A/?ref=app

19th Jun 2017, 6:02 PM
MUʜAMMED ɪʟʟYAS
MUʜAMMED ɪʟʟYAS - avatar
1 Answer
+ 3
here u should initialize n with 0 instead of 1 #include <iostream> using namespace std; int main() { char a[20]; char *b; int n=0; b=a; cout << "Enter a string \n"; cin >> a; while (*b!='\0') { switch(*b) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'A': case 'E': case 'I': case 'O': case 'U': ++n; } b++; } cout << "total vowels\n" << n; }
19th Jun 2017, 6:41 PM
Ashish Goyal
Ashish Goyal - avatar