Write a program that reads an unspecified number of uppercase or lowercase alphabets, and determines how many of them are vowels and how many are consonants. Enter zero to signify the end of the input.
1
Expert's answer
2016-11-10T10:45:08-0500
// // vowels_consonants.cpp // #include <iostream> #include <cctype> // for isalpha #include <cstring> // for strchr
using namespace std;
int main() { char ch; const char VOWELS[] ={"AaEeIiOoUuYy"}; int num_vowels = 0; int num_consonants = 0; cout << "Enter string of chars (0 to quit); " ; cin.get(ch); while (ch != '0'){ if (isalpha(ch) ){ if ( strchr(VOWELS,ch) != NULL ) ++num_vowels; else ++num_consonants; } cin.get(ch); } cout << "\nNumber of vowels is " << num_vowels <<",number of consonants is " << num_consonants; cout << endl; //keep console window open cout << "\nPress any key to contnue...\n"; cin.get(); cin.get(); return 0; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment