A simple program to ask the user to give a sentence and then the program will count the vowels, consonants, digits, and white space using a C++ programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg
=================================================
Want to support my the channel?

Paypal

https://paypal.me/jakerpomperada

Patreon

https://www.patreon.com/jakerpomperada

Thank you very much for your support.

Program Listing

#include <iostream>
#include <string>

using namespace std;


main()  {
    string sentence;
    int NumChars=0, VowelCount=0, ConsonantCount=0;
    int whitespace=0, digits=0;
    
    cout << "\n\n";
    cout << "\tCount Vowels, Consonants, Digits and White Space in C++";
    cout << "\n\n";
    cout << "\tEnter a Sentence :=> ";
    getline(cin,sentence);

    NumChars = sentence.length();

    for (int i=0; i < NumChars; i++) {
          switch(sentence.at(i)) {

              case 'a' : case 'A' :
              case 'e' : case 'E' :
              case 'i' : case 'I' :
              case 'o' : case 'O' :
              case 'u' : case 'U'  : VowelCount++;
                                     break;
              case 'b' : case 'B' :
              case 'c' : case 'C' :
              case 'd' : case 'D' :
              case 'f' : case 'F' :
              case 'g' : case 'G' :
              case 'h' : case 'H'  :

              case 'j' : case 'J'  :
              case 'k' : case 'K' :
              case 'l' : case 'L' :
              case 'm' : case 'M' :
              case 'n' : case 'N' :
              case 'p' : case 'P'  :

              case 'q' : case 'Q' :
              case 'r' : case 'R' :
              case 's' : case 'S' :
              case 't' : case 'T' :
              case 'w' : case 'W'  :

              case 'x' : case 'X' :
              case 'y' : case 'Y' :
              case 'z' : case 'Z' :  ConsonantCount++;
                                     break;
              case ' '  : whitespace++;
                           break;
              case '1' : case '2' :
              case '3' : case '4' :
              case '5' : case '6' :
              case '7' : case '8' :
              case '9' : case '0'  : digits++;



          }
    }
    cout << "\n\n";
    cout << "\t===  SUMMARY OF REPORTS =====\n";
    cout << "\n\n";
    cout << "\tNumber of Vowels      :=> " << VowelCount << ".\n";
    cout << "\tNumber of Consonants  :=> " << ConsonantCount << ".\n";
    cout << "\tNumber of Digits      :=> " << digits << ".\n";
    cout << "\tNumber of WhiteSpace  :=> " << whitespace << ".\n";
    cout << "\n\n";
    system("PAUSE");
}

Leave a Reply

Your email address will not be published.