Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- string getWord();
- int getVowel(string word);
- int getConsonants(string word);
- int displayVowel(int& sum1);
- int displayConsonants(int& sum2);
- int main()
- {
- string word;
- int sum1;
- int sum2;
- word = getWord();
- getVowel(word);
- getConsonants(word);
- displayVowel(sum1);
- displayConsonants(sum2);
- system("pause");
- return 0;
- }
- string getWord()
- {
- string word;
- cout << "what is the word ";
- getline(cin, word);
- return word;
- }
- int getVowel(string word)
- {
- int sum1 = 0;
- char temp;
- for (int i = 0; i < word.length(); i++)
- {
- if (isalpha(word.at(i)))
- {
- temp = word.at(i);
- temp = tolower(temp);
- if (temp == 'a' || temp == 'e' || temp == 'i' || temp == '0' || temp == 'u')
- sum1 += 1;
- }
- }
- return sum1;
- }
- int getConsonants(string word)
- {
- int sum2 = 0;
- char temp;
- for (int i = 0; i < word.length(); i++)
- if (isalpha(word.at(i)))
- {
- temp = word.at(i);
- temp = tolower(temp);
- if (temp != 'a' && temp != 'e' && temp != 'i' && temp != '0' && temp != 'u')
- sum2 += 1;
- }
- return sum2;
- }
- int displayVowel(int& sum1)
- {
- cout << "The total number of vowels are " << sum1 << endl;
- return sum1;
- }
- int displayConsonants(int& sum2)
- {
- cout << "The total number of consonants are " << sum2 << endl;
- return sum2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement