Enter astring: Program Youentered: \"Program\" This has7 characters, 2 vowels an
ID: 3613802 • Letter: E
Question
Enter astring: Program
Youentered: "Program"
This has7 characters, 2 vowels and 5 consonants (C-String).
#include <cstring>
using namespace std;
//Prototype functions
int vowl1ct(char, char);
int vowl2ct(char, char);
int main()
{
//Declare variables
string str1;
int size1 = 0, count = 0, cons1 =0;
cout << "Please enter a string with nospaces!" << endl <<endl;
cin >> str1;
cout << endl;
cout << "You Entered: "<< str1 << endl <<endl;
size1 = str1.length();
//Loop through to find the vowel count
for (inti = 0; i < str1.length(); i++)
{
count += vowl1ct(str1.at(i),'a');
count += vowl1ct(str1.at(i),'e');
count += vowl1ct(str1.at(i),'i');
count += vowl1ct(str1.at(i),'o');
count += vowl1ct(str1.at(i),'u');
count += vowl1ct(str1.at(i),'A');
count += vowl1ct(str1.at(i),'E');
count += vowl1ct(str1.at(i),'I');
count += vowl1ct(str1.at(i),'O');
count += vowl1ct(str1.at(i),'U');
}
//Output to the screen the results
cons1 = size1 - count;
cout << "This has "<< size1 << " characters," << count <<"vowels and " << cons1<< " consonants (String Data Type)."<< endl << endl;
system("PAUSE");
}
//The vowel function
int vowl1ct(char ch, char vowl)
{
int count = 0;
if (ch == vowl)
return 1;
else
return 0;
}
Explanation / Answer
please rate - thanks not how I would have done it, but how you would have done it #include #include #include using namespace std; //Prototype functions int vowl1ct(char, char); int main() { //Declare variables string str1; int size1 = 0, count = 0, cons1 = 0; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.