Oct 4, 2016 at 8:37pm UTC
Line 20: What do you think this statement does? Hint: it does nothing.
Line 26: Why are you using x[i] as the upper limit of your loop?
You're counting the number of characters using our while loop at line 18, but you overlay the count (i) at line 26.
Oct 4, 2016 at 8:42pm UTC
Last edited on Oct 4, 2016 at 8:43pm UTC
Oct 4, 2016 at 9:29pm UTC
Ok thankes.
What the difference between (count = count++;) to (count++;) ?
Oct 5, 2016 at 6:56am UTC
count = count++; is undefined behaviour.
Oct 5, 2016 at 8:35am UTC
"y" isn't a vowel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#include <iostream>
using namespace std;
int main()
{
string x;
int count = 0;
cout << "Enter string" << endl ;
getline (cin, x);
cout << "The number of vowels are : " << endl;
for (int i = 0; i < x.length(); i++)
{
if ( (x[i] == 'a' ) || (x[i] == 'o' ) || (x[i] == 'u' ) ||(x[i] == 'i' ) ||(x[i] == 'e' ) )
{
count=count+1;
}
}cout << count << endl;
return 0;
}
Last edited on Oct 5, 2016 at 8:36am UTC