Page 49 - DCAP404 _Object Oriented Programming
P. 49

Object-oriented Programming




                    Notes          #  include  <iostream.h>
                                   int  main  (  )
                                   {
                                          int  constant,  vowel  ;
                                          char  inp  ;
                                          consonant  =  vowel  0  ;
                                          do

                                          {
                                                 inp  =  ‘  ;
                                                 cout  <<  endl.  <<  “  Enter  a  character  (  !  to  quit  )  “;
                                                 cin  >>  inp;
                                                 switch  (  inp)
                                                 {
                                                        case  ‘A‘      :

                                                        case    ‘a‘    :
                                                        case  ‘E‘      :
                                                        case  ‘e‘      :
                                                        case  ‘I‘             :
                                                        case  ‘i‘             :
                                                        case  ‘O‘      :
                                                        case  ‘o‘      :
                                                        case  ‘U‘      :
                                                        case  ‘u‘      :      vowel    =  vowel  +    1;

                                                                              break  ;
                                                        case  ‘  !‘    :      break;
                                                        default        :      consonant  =  consonant  +  1;
                                                 }
                                          }  while  (  inp  !  =  ‘!‘)
                                          if  (  constant  >  vowel  )
                                          cout  <<  endl  <<  “  Consonant  count  greater  than  vowel  count”  ;

                                          else  if  (  consonant  <  vowel  )
                                                 cout  <<  endl  <  “  Vowel  count  greater  than  consonant  count”;
                                          else
                                                   cout  <<  endl  <<  “  Vowel  !  and  consonant  counts  are  equal  “;
                                          return  0;
                                   }






          42                                LOVELY PROFESSIONAL UNIVERSITY
   44   45   46   47   48   49   50   51   52   53   54