topical media & game development

talk show tell print

basic-program-code-03-Ex3-06.c

? / basic-program-code-03-Ex3-06.c


  // Ex3_06.cpp
  // Multiple case actions
  include <iostream>
  
  using std::cin;
  using std::cout;
  using std::endl;
  
  int main()
  {
     char letter = 0;
     cout << endl
          << "Enter a small letter: ";
     cin >> letter;
  
     switch(letter*(letter >= 'a' && letter <= 'z'))
     {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u': cout << endl << "You entered a vowel.";
                  break;
  
        case 0: cout << endl << "That is not a small letter.";
                break;
  
        default: cout << endl << "You entered a consonant.";
     }
     cout << endl;
     return 0;
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.