Question: Write a program in C. A binary representation for the properties of a character is a binary string b0b1b2b3b4b5b6, i.e. bi {0,1} for 0

Write a program in C. A binary representation for the properties of a character is a binary string b0b1b2b3b4b5b6, i.e. bi {0,1} for 0 <= i <=6, is defined as following,

If the char is alphanumeric character, then b0 = 1. Otherwise, b0 = 0. Alphanumeric characters are digits, lowercase letters and uppercase letters.

If the char is an uppercase letter, then b1 = 1. Otherwise, b1 = 0.

If the char is a lowercase letter, then b2 = 1. Otherwise, b2 = 0. If the char is a vowel, then b3 = 1. Otherwise, b3 = 0.

If the char is a digit, then b4 = 1. Otherwise, b4 = 0. If the char is a hexadecimal digit, then b5 = 1. Otherwise, b5 = 0. Hexadecimal digits are f0; 1; 2; 3; 4; 5; 6; 7; 8; 9; a; b; c; d; e; f; A;B;C;D;E; Fg.

If the char is a punctuation character, then b6 = 1. Otherwise, b6 = 0. Write a program that reads in a char and prints the binary representation of the char.

Example output: $ ./binaryrep Please enter a character: a

The properties of the character can be represented by 1011010

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!