#CoolCodez

Situation: User inputs a string and code tells you the number of lower case and upper case alphabets, numbers, spaces, and special characters.

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class Array
{
      private: char string[30];
      int len, vowel, conso, upper, lower, space, special, dig;

      public:
      Array()
      {
           len=vowel=conso-lower=upper=dig=space=special=0;
      }

      void process()
      {
           cout<<"\n\t Enter string: ";
           gets(string);
      }

      void display()
      {
          cout<<"\n\t Enter string: ";
          while (string[len]!='\0')

          cout<<string[len]; 
          if(string[len])>='a'&&string[len]<='z') 
          { 
                  lower++; 
                  if(string[len])=='a'||string[len]=='e'|| string[len]=='i'||string[len]=='o'||string[len]=='u') 
                  { 
                           vowel++; 
                  } 
                  else 
                  { 
                           conso; 
                  } 
          } 
          else if(string[leng]>='A'&&string[len]<='Z'||) 
          { 
                  upper++; 
                  if(string[len])=='A'||string[len]=='E'|| string[len]=='I'||string[len]=='O'||string[len]=='U') 
                  { 
                            vowel++; 
                  } 
                  else 
                  {         
                            conso++: 
                  } 
           } 
           else if(string[len]>='0'&&string[len]<='9')
           {
                  dig++;
           }
           else if(string[len]=' ')
           {
                  space++;
           }
           else
           {
                 special++;
           }
           len++;
           }
    }
   
    void reverse()
    {
           len--;
           cout<<"\n\tReverse string= "; while (len>=0)
           {
                cout<<string[len];
                len--;
           }
    }

    void alpha()
    {
           cout<<"\n\t Vowel ="<<vowel;
           cout<<"\n\t Consonant= "<<conso;
    }

    void type()
    {
           cout<<"\n\t Upper Case ="<<upper;
           cout<<"\n\t Lower Case ="<<lower;
           cout<<"\n\t Digits ="<<dig;
           cout<<"\n\t Space ="<<space;
           cout<<"\n\t Special characters ="<<special;
    };

    void main()
    {
           clrscr();
           Array obj;
           obj.process();
           obj.display();
           obj.reverse();
           obj.alpha();
           obj.type();
           getch();
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s