Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int isVowel(char character)
- {
- //character = character - 32;
- string vowels = "aeiou";
- int n = vowels.length();
- for (int i = 0; i < n; i++)
- {
- if (character == vowels[i])
- {
- cout << vowels[i];
- return 1;
- }
- else
- {
- cout << vowels[i];
- return 0;
- }
- }
- }
- int countVowels(string stringMy) // function that returns the count of vowels
- {
- int count = 0;
- for (int i = 0; i < stringMy.length(); i++)
- {
- if (isVowel(stringMy[i])) // check if character is vowel
- count ++;
- }
- return count;
- }
- int main()
- {
- string stringMy = "educative";
- cout << countVowels(stringMy);
- }
Advertisement
Add Comment
Please, Sign In to add comment