daily pastebin goal
89%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     string line;
  7.     int vowels, consonants, digits, spaces;
  8.  
  9.     vowels =  consonants = digits = spaces = 0;
  10.  
  11.     cout << "Enter a line of string: ";
  12.     getline(cin, line);
  13.  
  14.     for(int i = 0; i < line.length(); ++i)
  15.     {
  16.         if(line[i]=='a' || line[i]=='e' || line[i]=='i' ||
  17.            line[i]=='o' || line[i]=='u' || line[i]=='A' ||
  18.            line[i]=='E' || line[i]=='I' || line[i]=='O' ||
  19.            line[i]=='U')
  20.         {
  21.             ++vowels;
  22.         }
  23.         else if((line[i]>='a'&& line[i]<='z') || (line[i]>='A'&& line[i]<='Z'))
  24.         {
  25.             ++consonants;
  26.         }
  27.         else if(line[i]>='0' && line[i]<='9')
  28.         {
  29.             ++digits;
  30.         }
  31.         else if (line[i]==' ')
  32.         {
  33.             ++spaces;
  34.         }
  35.     }
  36.  
  37.     cout << "Vowels: " << vowels << endl;
  38.     cout << "Consonants: " << consonants << endl;
  39.     cout << "Digits: " << digits << endl;
  40.     cout << "White spaces: " << spaces << endl;
  41.  
  42.     return 0;
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top