home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / learn / else1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-07  |  408 b   |  21 lines

  1. /* ELSE1.C: Demonstrate else-if construct. */
  2.  
  3. #include <stdio.h>
  4. #include <conio.h>
  5. #define  B_KEY  'b'
  6. #define  ENTER_KEY '\r'
  7.  
  8. main()
  9. {
  10.    char ch;
  11.    printf( "Press the b key to hear a bell.\n" );
  12.    ch = getch();
  13.    if( ch == B_KEY )
  14.       printf( "Beep!\a\n" );
  15.    else
  16.       if( ch == ENTER_KEY )
  17.      printf( "What a boring selection...\n" );
  18.    else
  19.       printf( "Bye bye.\n" );
  20. }
  21.