SHARE
TWEET

Untitled

a guest Oct 13th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. #pragma warning(disable:4996)
  5. #ifndef __CHARCODES__
  6. #define __CHARCODES__
  7. // Type codes...
  8. #define LETTER       1
  9. #define NUMBER       2
  10. #define SYMBOL       3
  11.  
  12. // Sub-type codes...
  13. #define VOWEL        4
  14. #define CONSONANT    5
  15. #define ODD          6
  16. #define EVEN         7
  17. #define UPPER_ASCII  8
  18. #define LOWER_ASCII  9
  19. #define LOWER_UPPER_ASCII_BOUNDARY 127
  20. #endif
  21.  
  22. int main() {
  23.     unsigned char keyStroke = 0;
  24.     int typeCode = -1, subTypeCode = -1;
  25.  
  26.     // GET THE KEYSTROKE (remember to clean phantoms)
  27.     scanf("%c", &keyStroke);
  28.     rewind(stdin);
  29.     // ANALYZE THE KEYSTROKE (IF, IF-ELSE, IF-ELSE-CHAIN here)
  30.     if(keyStroke >= 'a' && keyStroke <= 'z' || keyStroke >= 'A' && keyStroke <= 'Z') {
  31.         typeCode = 1;
  32.         if (keyStroke == 'a' || keyStroke == 'e' || keyStroke == 'i' || keyStroke == 'o' || keyStroke == 'u' || keyStroke == 'A' || keyStroke == 'E' || keyStroke == 'I' || keyStroke == 'O' || keyStroke == 'U') {
  33.             subTypeCode = 4;
  34.         }
  35.         else {
  36.             subTypeCode = 5;
  37.         }
  38.     }
  39.     else if (keyStroke >= '0' && keyStroke <= '9') {
  40.         typeCode = 2;
  41.         if (keyStroke % 2 == 0) {
  42.             subTypeCode = 7;
  43.         }
  44.         else {
  45.             subTypeCode = 6;
  46.  
  47.         }
  48.     }
  49.     else {
  50.         typeCode = 3;
  51. //      if (keyStroke != (keyStroke >= 'a' && keyStroke <= 'z' || keyStroke >= 'A' && keyStroke <= 'Z') && (keyStroke != keyStroke >= '0' && keyStroke <= '9') && (keyStroke <= LOWER_UPPER_ASCII_BOUNDARY)) {
  52.         if (keyStroke <= LOWER_UPPER_ASCII_BOUNDARY) {
  53.             subTypeCode = LOWER_ASCII;
  54.         }
  55.         else {
  56.             subTypeCode = UPPER_ASCII;
  57.         }
  58.     }
  59.     // DISPLAY RESULTS BASED ON SET CODES (SWITCH-CASE)
  60.     switch (typeCode) {
  61.     case 1:
  62.         printf("That is a LETTER.\n");
  63.         break;
  64.     case 2:
  65.         printf("That is a NUMBER.\n");
  66.         break;
  67.     case 3:
  68.         printf("That is a SYMBOL.\n");
  69.         break;
  70.     }
  71.     switch (subTypeCode) {
  72.     case 4:
  73.         printf("Which is a VOWEL.\n");
  74.         break;
  75.     case 5:
  76.         printf("Which is a CONSONANT.\n");
  77.         break;
  78.     case 6:
  79.         printf("Which is ODD.\n");
  80.         break;
  81.     case 7:
  82.         printf("Which is EVEN.\n");
  83.         break;
  84.     case 8:
  85.         printf("Which is in the UPPER_ASCII.\n");
  86.         break;
  87.     case 9:
  88.         printf("Which is in the LOWER_ASCII.\n");
  89.         break;
  90.     }
  91.  
  92.     _getch();
  93.     return 0;
  94. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top