Sunday, August 26, 2018

Count Vowel, Consonants, Digits and Whitespace in C++

In this program will ask the user to give a sentence and then the program using switch statement will count the vowels, consonants, digits and white space using C++.

I am currently accepting programming work, it project, school 

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 in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com, jakerpomperada@aol.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

My personal website is http://www.jakerpomperada.com


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 << "Enter a String :=> ";
    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 << " \n ===  SUMMARY OF REPORTS ===== ";
    cout << "\n\n";
    cout << "\nNumber of Vowels     :=> " << VowelCount << ".";
    cout << "\nNumber of Consonants :=> " << ConsonantCount << ".";
    cout << "\nNumber of Digits     :=> " << digits << ".";
    cout << "\nNumber of WhiteSpce  :=> " << whitespace << ".";
    cout << "\n\n";
    system("PAUSE");
}

22 comments:

  1. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    Devops training in sholinganallur

    ReplyDelete
  2. This is very good content you share on this blog. it's very informative and provide me future related information.

    Blueprism training in Chennai

    Blueprism training in Bangalore

    ReplyDelete
  3. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. R Programming Training institutes in Chennai

    ReplyDelete
  4. Brilliant ideas that you have share with us.It is really help me lot and i hope it will help others also.update more different ideas with us.
    Java Training in Bangalore
    Java training courses near me
    Java Training Institute in Vadapalani
    Java Courses in OMR

    ReplyDelete
  5. You actually make it seem really easy along with your presentation however I in finding this matter
    to be really something which I think I'd by no means understand. It seems too complicated and very wide for me. I'm taking a look.keep share some more .
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  6. Join the Python Course in Hyderabad and get a bright career in Python when you join AI Patasala. We aid aspirants in pursuing their careers by utilizing this platform.
    AI Patasala Python Course

    ReplyDelete
  7. Pull- up your socks and knot your tie. Gonna have a good salary package job after completing Big-data Hadoop training in Chennai at Infycle. Infylce is completely for Software training and placement by friendly trainees, good atmosphere, 200% practical classes, and more.

    ReplyDelete