Skip to content

Instantly share code, notes, and snippets.

@Mike427
Last active September 22, 2018 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mike427/ec0e894e1d336605dc7189b53274e3b0 to your computer and use it in GitHub Desktop.
Save Mike427/ec0e894e1d336605dc7189b53274e3b0 to your computer and use it in GitHub Desktop.
number of vowels
#include <iostream>
using namespace std;
bool isVowel(char ch);
int main(){
int NumOfVowels = 0;
char ch;
cout << "Input a sequence of characters:" << endl;
cin.get(ch);
do{
if (isVowel(ch) == true){
NumOfVowels++;
}
}while (cin.get(ch));
cout << NumOfVowels << " vowels in this sentence.";
return 0;
}
bool isVowel(char ch){
if(ch=='a'|| ch=='A' || ch=='e'|| ch=='E' || ch=='i'|| ch=='I' || ch=='o'|| ch=='O' || ch=='u'|| ch=='U')
return true;
else
return false;
}
/*was thinking of using a switch with case but haven't decided
switch(ch)
{
case 'A':
return true;
break;
case 'E':
return true;
break;
case 'I':
return true;
break;
case 'O':
return true;
break;
case 'U':
return true;
break;
case 'a':
return true;
break;
case 'e':
return true;
break;
case 'i':
return true;
break;
case 'o':
return true;
break;
case 'u':
return true;
break; */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment