home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc / qc25 / switch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-15  |  413 b   |  24 lines

  1. /* SWITCH.C: Demonstrate switch statement. */
  2.  
  3. #include <stdio.h>
  4. #include <conio.h>
  5.  
  6. main()
  7. {
  8.    char ch;
  9.    printf( "Press the b key to hear a bell.\n" );
  10.    ch = getch();
  11.    switch( ch )
  12.    {
  13.       case 'b':
  14.          printf( "Beep!\a\n" );
  15.          break;
  16.       case '\r':
  17.          printf( "Enter\n" );
  18.          break;
  19.       default:
  20.          printf( "Bye bye" );
  21.          break;
  22.    }
  23. }
  24.