Program to find the ASCII value of a character is discussed here. Given a character as input, the ASCII value of the character is displayed as output.
A character variable holds the ASCII value (an integer number between 0 and 127) rather than that character itself. That value is known as the ASCII value.
For example, consider the given character as input.
Input: S
Output: 83
Input: s
Output: 115
The program to find the ASCII value of a character is given below.
@@coding::1@@
In this program, the user is asked to input a character which is stored on variable ch.
The ASCII value of that character is stored in variable ch,rather than that variable itself.
When %d format string is used, 115 (ASCII value of ‘s’) is displayed.
When %c format string is used, ‘s’ itself is displayed.
Recommended Programs