Vowels - Consonants Exceptional Handling

#include <iostream>
#include <string.h>
using namespace std;
int main() {
char a[30];
  int len, i, vow=0, cons=0;
  cin>>a;
  len = strlen(a);
  for(i=0; i<len; i++)
    {
      try
        {
          if(a[i]>=65 && a[i] <91 || a[i]>=97 && a[i] < 123)
            {
              if(a[i] == 'a' || a[i] == 'e' || a[i] == 'i' || a[i] == 'o' || a[i] == 'u' || a[i] =='A' || a[i] == 'E' || a[i] == 'I' || a[i] == 'O' || a[i] == 'U')
                {
                  vow++;
                }
              else
                  cons++;
            }
          else
            {
              throw a[i];
            }
        }
   
  catch(char c)
    {
      cout<<"Exception Caught Numeric Value";
      return 0;
    }
    }

      cout<<"Vowels="<<vow;
      cout<<endl<<"Consonants="<<cons;

return 0;
}

3 comments: