+ 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
1 Antwort
+ 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;
}