home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap07 / asimov.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-05  |  713 b   |  31 lines

  1. /* asimov.c -- illustrates how to initialize an      */
  2. /*             array with starting values            */
  3.  
  4. #define MAXL 16
  5. char Letters[MAXL] = { 
  6.     'e', 'I', 'a', 'N', 'o', 'R', 'O', 'o',
  7.     'u', 't', 'o', 'R', 'l', 'o', 'B', 'b', 
  8. };
  9.  
  10. main()
  11. {
  12.     int num, i;
  13.  
  14.     printf("Guess my identity with numbers.\n");
  15.     printf("(any non number quits)\n\n");
  16.  
  17.     while (scanf("%d", &num) == 1)
  18.         {
  19.         if (num <= 0)
  20.             {
  21.             printf("Guesses must be above zero\n");
  22.             continue;
  23.             }
  24.         for (i = 1; i <= num; ++i)
  25.             {
  26.             printf("%c", Letters[(i * num) % MAXL]);
  27.             }
  28.         printf("\n");
  29.         }
  30. }
  31.