ASCII is the abbreviation of American Standard Code for Information Interchange. It is a character encoding standard for electronic communication. ASCII encodes 128 specified characters into seven-bit integers. It contains the numbers from 0 - 9, the upper and lower case English letters from A to Z and some special characters.
The following C program converts a given ASCII value to its equivalent character. The algorithm, time complexity and pseudocode of the program have also been added.
Page content(s):
Additional content(s):
1. Algorithm for ASCII to Character Conversion
1. Take an ASCII value (Integer (0 - 127)) as input.
2. Do cast the integer to the corresponding character.
3. Return the result
2. Pseudocode for ASCII to Character Conversion
Input : An integer (0 - 127) $i$
Output : A character $c$
1. Procedure toCharacter($i$):
2.
3. End Procedure
3. Time complexity for ASCII to Character Conversion
Time Complexity: O(1)
4. C Program & output for ASCII to Character Conversion
/******************************************* alphabetacoder.com C program for ASCII to character conversion ********************************************/ #include <stdio.h> int main() { // declare variables char x; int v = 80; //convert and store the corresponding character x = (char) v; // display result printf("Equivalent character of ASCII value %d is = %c", v, x); return 0; }
Output
Equivalent character of ASCII value 80 is = P