ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as ‘a’ or ‘@’ or an action of some sort.
ASCII lookup table is a tabular representation of corresponding values associated to a character i.e. we can lookup the corresponding octal, decimal, hexadecimal or HTML ASCII of a character.
Here, we are implementing an ASCII lookup table which takes a character as an input and returns the equivalent octal, decimal, hexadecimal and HTML ASCII value for the character. This ASCII lookup table works for alphabets, digits, operators, separators and special symbols.
Input character = @ Output : Octal value: 100 Decimal value: 64 Hexadecimal value: 40 HTML value: &#064;
Step 1: Convert given character into it’s equivalent ASCII in decimal form. This can be done by implicitly typecasting the character into an integral value(or subtracting by null).
Step 2: The value computed in step 1 becomes the decimal representation of the character. Convert the decimal value in octal and hexadecimal forms to obtain the ASCII of the input character into the given formats.
Step 3: Add characters &# as prefix and ; as postfix of the decimal ASCII, the expression obtained becomes the HTML ASCII of the given character.
This way we can easily implement the ASCII lookup table. Follow the code below to see the implementation.
Octal value: 100 Decimal value: 64 Hexadecimal value: 40 HTML value: &#064;
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Program to print ASCII Value of a character
- Program to find the XOR of ASCII values of characters in a string
- Program to find the product of ASCII values of characters in a string
- Program to find the largest and smallest ASCII valued characters in a string
- Program to implement FLAMES game
- Program to print multiplication table of a number
- Multiplication table till N rows where every Kth row is table of K upto Kth term
- ascii() in Python
- Sub-strings having exactly k characters that have ASCII value greater than p
- Count of alphabets having ASCII value less than and greater than k
- Convert the ASCII value sentence to its equivalent string
- Count and Print the alphabets having ASCII value in the range [l, r]
- Count and Print the alphabets having ASCII value not in the range [l, r]
- Average of ASCII values of characters of a given string
- Sums of ASCII values of each word in a sentence
- Convert a string to hexadecimal ASCII values
- Print given sentence into its equivalent ASCII form
- Map function and Dictionary in Python to sum ASCII values
- Minimize ASCII values sum after removing all occurrences of one character
- Convert all lowercase characters to uppercase whose ASCII value is co-prime with k
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nitin mittal