home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tyc / list13_8.c < prev    next >
C/C++ Source or Header  |  1993-10-16  |  884b  |  42 lines

  1.  /* Another use of the switch statement. */
  2.  
  3.  #include <stdio.h>
  4.  #include <stdlib.h>
  5.  
  6.  main()
  7.  {
  8.      int reply;
  9.  
  10.      while (1)
  11.      {
  12.          puts("Enter a value between 1 and 10, 0 to exit: ");
  13.          scanf("%d", &reply);
  14.  
  15.          switch (reply)
  16.          {
  17.              case 0:
  18.                  exit(0);
  19.              case 1:
  20.              case 2:
  21.              case 3:
  22.              case 4:
  23.              case 5:
  24.                  {
  25.                  puts("You entered 5 or below.");
  26.                  break;
  27.                  }
  28.              case 6:
  29.              case 7:
  30.              case 8:
  31.              case 9:
  32.              case 10:
  33.                  {
  34.                  puts("You entered 6 or higher.");
  35.                  break;
  36.                  }
  37.              default:
  38.                  puts("Between 1 and 10, please!");
  39.          }
  40.      }
  41.  }
  42.