Question: Assignment Write a program that prompts the user to enter a single keystroke and stores the character pressed in a char variable. The program then
Assignment Write a program that prompts the user to enter a single keystroke and stores the character pressed in a char variable. The program then processes the keystroke and determines if the keystroke was a letter, numeral, or symbol. If the keystroke was a letter, display a message indicating whether the letter is a vowel or consonant. If the character is a numeral, information about whether the numeral is even or odd is displayed. If the character is a symbol, information is displayed indicating whether the symbol is found in the lower ASCII table (7-bit representations) or the upper ASCII table (8-bit representations). The tests for determining if the input was a letter or numeral should be accomplished manually with a conditional logic test taking advantage of character adjacency patterns in the ASCII table. The use of the functions isalpha() and isdigit() should be avoided. Your program should make use of #define codes to classify the keystroke. Your program should contain at least one instance of an IF, IF-ELSE, IF-ELSE-CHAIN, and SWITCH-CASE structure. Use the following shell to start your program:
#include
#ifndef __CHARCODES__
#define __CHARCODES__
// Type codes...
#define LETTER 1
#define NUMBER 2
#define SYMBOL 3
// Sub-type codes...
#define VOWEL 4
#define CONSONANT 5 #define ODD 6 #define EVEN 7 #define UPPER_ASCII 8 #define LOWER_ASCII 9 #endif int main() { char keyStroke = 0; int typeCode = -1, subTypeCode = -1; // GET THE KEYSTROKE (remember to clean phantoms) // ANALYZE THE KEYSTROKE (IF, IF-ELSE, IF-ELSE-CHAIN here) // DISPLAY RESULTS BASED ON SET CODES (SWITCH-CASE) return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
