home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tybc4 / switch1.cpp < prev    next >
C/C++ Source or Header  |  1993-03-19  |  719b  |  37 lines

  1. // Program demonstrates the multiple-alternative switch statement
  2.  
  3. #include <iostream.h>
  4.  
  5. main()
  6. {
  7.   char c;
  8.   cout << "Enter a character : ";
  9.   cin >> c;
  10.   switch (c) {
  11.     case 'A':
  12.     case 'B':
  13.     case 'C':
  14.     case 'D':
  15.     // other case labels
  16.       cout << "You entered an uppercase letter\n";
  17.       break;
  18.     case 'a':
  19.     case 'b':
  20.     case 'c':
  21.     case 'd':
  22.     // other case labels
  23.       cout << "You entered a lowercase letter\n";
  24.       break;
  25.     case '0':
  26.     case '1':
  27.     case '2':
  28.     case '3':
  29.     // other case labels
  30.       cout << "You entered a digit\n";
  31.       break;
  32.     default:
  33.       cout << "You entered a non-alphanumeric character\n";
  34.   }
  35.   return 0;
  36. }
  37.